-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: late enrollment should be less sensitive to courserun state #1130
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1130 +/- ##
==========================================
+ Coverage 87.00% 87.03% +0.03%
==========================================
Files 388 388
Lines 8066 8070 +4
Branches 1939 1979 +40
==========================================
+ Hits 7018 7024 +6
+ Misses 999 997 -2
Partials 49 49 ☔ View full report in Codecov by Sentry. |
a127c94
to
3cd2e68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 nits, great job! Approved to unblock 👍🏽
src/components/app/data/utils.js
Outdated
!('seats' in courseRun) || !courseRun.seats?.length, | ||
!('marketingUrl' in courseRun) || !courseRun.marketingUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] I believe ?
after courseRun
should achieve the same results as !('seats' in courseRun)
const baseNonAvailalbeCheck = [
isArchived(courseRun),
!courseRun?.seats?.length,
!courseRun?.marketingUrl,
]
src/components/app/data/utils.js
Outdated
|
||
// isEnrollableBufferDays is used as a heuristic to determine if the late enrollment feature is enabled. | ||
return course.courseRuns.filter( | ||
isEnrollableBufferDays === undefined ? standardAvailableCourseRunsFilter : lateEnrollmentAvailableCourseRunsFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit/question] is there any chance of isEnrollableBufferDays
to return as a null? Could !isEnrollableBufferDays
achieve the same results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking along the same lines, @brobro10000. But !isEnrollableBufferDays
could, in theory, be 0
would be truthy with the check on !isEnrollableBufferDays
(when it is defined, it returns the value of a constant 30
but what if it were to change to 0
for some reason, or otherwise be configurable/dynamic).
Maybe checking for whether the value is a number? The (below) latter !isNaN
check is because typeof NaN === 'number'
is also true.
typeof isEnrollableBufferDays === 'number' && !isNaN(isEnrollableBufferDays) ? lateEnrollmentAvailableCourseRunsFilter : standardAvailableCourseRunsFilter,
Another alternative suggestion might be use the util functions in this repo like isDefined
, isDefinedAndNotNull
, etc.
isDefinedAndNotNull(isEnrollableBufferDays) ? lateEnrollmentAvailableCourseRunsFilter : standardAvailableCourseRunsFilter,
[unrelated nit / follow-up] I wonder if we might want to consider eventually renaming isEnrollableBufferDays
since it seems to indicate its value is a boolean due to the is
prefix, but it returns an integer constant or isn't defined. Perhaps something like lateEnrollmentBufferDays
would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with 2 small nits/suggestions to consider :)
src/components/app/data/utils.js
Outdated
const baseNonAvailableChecks = [ | ||
isArchived(courseRun), | ||
// The next two checks are in lieu of isMarketable which is otherwise overly sensitive to courserun state. | ||
!('seats' in courseRun) || !courseRun.seats?.length, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit/suggestion]: Perhaps updated slightly / simplified a bit:
const baseNonAvailableChecks = [
isArchived(courseRun),
!courseRun.seats?.length,
// ...
];
The check ('seats' in courseRun)
is handled by the optional chaining of ?.
in courseRun.seats?.length
. I don't think there needs to be ?.
in courseRun?.seats
, though, since other existing code paths assume courseRun
exists (e.g., courseRun.isMarketable
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Similar to Hamzah's comment below)
src/components/app/data/utils.js
Outdated
|
||
// isEnrollableBufferDays is used as a heuristic to determine if the late enrollment feature is enabled. | ||
return course.courseRuns.filter( | ||
isEnrollableBufferDays === undefined ? standardAvailableCourseRunsFilter : lateEnrollmentAvailableCourseRunsFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking along the same lines, @brobro10000. But !isEnrollableBufferDays
could, in theory, be 0
would be truthy with the check on !isEnrollableBufferDays
(when it is defined, it returns the value of a constant 30
but what if it were to change to 0
for some reason, or otherwise be configurable/dynamic).
Maybe checking for whether the value is a number? The (below) latter !isNaN
check is because typeof NaN === 'number'
is also true.
typeof isEnrollableBufferDays === 'number' && !isNaN(isEnrollableBufferDays) ? lateEnrollmentAvailableCourseRunsFilter : standardAvailableCourseRunsFilter,
Another alternative suggestion might be use the util functions in this repo like isDefined
, isDefinedAndNotNull
, etc.
isDefinedAndNotNull(isEnrollableBufferDays) ? lateEnrollmentAvailableCourseRunsFilter : standardAvailableCourseRunsFilter,
[unrelated nit / follow-up] I wonder if we might want to consider eventually renaming isEnrollableBufferDays
since it seems to indicate its value is a boolean due to the is
prefix, but it returns an integer constant or isn't defined. Perhaps something like lateEnrollmentBufferDays
would make sense.
18ec1b3
to
f3634b6
Compare
f3634b6
to
b6982d7
Compare
ENT-9259