Skip to content
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

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

pwnage101
Copy link
Contributor

ENT-9259

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.03%. Comparing base (6d1860b) to head (b6982d7).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-9259 branch 2 times, most recently from a127c94 to 3cd2e68 Compare July 24, 2024 18:50
Copy link
Member

@brobro10000 brobro10000 left a 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 👍🏽

Comment on lines 493 to 494
!('seats' in courseRun) || !courseRun.seats?.length,
!('marketingUrl' in courseRun) || !courseRun.marketingUrl,
Copy link
Member

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,
]


// isEnrollableBufferDays is used as a heuristic to determine if the late enrollment feature is enabled.
return course.courseRuns.filter(
isEnrollableBufferDays === undefined ? standardAvailableCourseRunsFilter : lateEnrollmentAvailableCourseRunsFilter,
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

@adamstankiewicz adamstankiewicz left a 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 :)

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,
Copy link
Member

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).

Copy link
Member

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)


// isEnrollableBufferDays is used as a heuristic to determine if the late enrollment feature is enabled.
return course.courseRuns.filter(
isEnrollableBufferDays === undefined ? standardAvailableCourseRunsFilter : lateEnrollmentAvailableCourseRunsFilter,
Copy link
Member

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.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-9259 branch 2 times, most recently from 18ec1b3 to f3634b6 Compare July 24, 2024 21:00
@pwnage101 pwnage101 merged commit e354666 into master Jul 24, 2024
7 checks passed
@pwnage101 pwnage101 deleted the pwnage101/ENT-9259 branch July 24, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants