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

feat: assign by course run implementation #1292

Merged
merged 23 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
448ea95
feat: assign by course run implementation
brobro10000 Sep 3, 2024
6ebabaf
chore: optimize and cleanup
brobro10000 Sep 4, 2024
0e51dec
chore: Normalize failing tests
brobro10000 Sep 4, 2024
499af78
chore: fix tests
brobro10000 Sep 5, 2024
fddd9ad
chore: fix tests 2
brobro10000 Sep 6, 2024
c864670
feat: default stale course start dates to today
brobro10000 Sep 10, 2024
c23e647
chore: PR feedback 1
brobro10000 Sep 11, 2024
5b1d9b4
chore: PR feedback 2
brobro10000 Sep 12, 2024
986e726
refactor: Updates logic for start date threshold
brobro10000 Sep 12, 2024
622e2fe
chore: PR feedback 3
brobro10000 Sep 12, 2024
fe76d73
chore: PR feedback 4
brobro10000 Sep 12, 2024
a68a9b1
feat: support late enrollment flow
brobro10000 Sep 13, 2024
cb95c12
chore: fix tests
brobro10000 Sep 13, 2024
07991f3
feat: update enroll-by date threshold to consider refund threshold
brobro10000 Sep 16, 2024
3f054f6
feat: update modal allocation help text enroll by date
brobro10000 Sep 16, 2024
0d18f45
feat: adds price range for lc variant based assignments
brobro10000 Sep 16, 2024
4b39fc5
chore: PR feedback
brobro10000 Sep 16, 2024
a2495ea
chore: PR feedback 2
brobro10000 Sep 16, 2024
765c86d
chore: PR feedback 3
brobro10000 Sep 16, 2024
027fee7
feat: explicitly handle late enrollment case
brobro10000 Sep 17, 2024
eba4828
chore: refine enrollby and start date logic
brobro10000 Sep 17, 2024
938303b
chore: PR feedback
brobro10000 Sep 17, 2024
b5f6cd3
fix: remove 90 day check for enrollment threshold
brobro10000 Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/components/learner-credit-management/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@

export const hasTimeToComplete = ({ end, weeksToComplete }) => {
if (!weeksToComplete || !end) {
return true;

Check warning on line 577 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L577

Added line #L577 was not covered by tests
}
const today = dayjs();
const differenceInWeeks = dayjs(end).diff(today, 'week');
Expand Down Expand Up @@ -606,7 +606,7 @@
if (isCourseSelfPaced({ pacingType })) {
if (hasTimeToComplete({ end, weeksToComplete }) || isWithinMinimumStartDateThreshold({ start })) {
// always today's date (incentives enrollment)
return todayToIso;

Check warning on line 609 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L609

Added line #L609 was not covered by tests
}
}
return startDateIso;
Expand All @@ -614,11 +614,11 @@

export const getNormalizedEnrollByDate = (enrollBy) => {
if (!enrollBy) {
return null;

Check warning on line 617 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L617

Added line #L617 was not covered by tests
}
const ninetyDaysFromNow = dayjs().add(DAYS_UNTIL_ASSIGNMENT_ALLOCATION_EXPIRATION, 'days');
if (dayjs(enrollBy).isAfter(ninetyDaysFromNow)) {
return ninetyDaysFromNow.toISOString();

Check warning on line 621 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L621

Added line #L621 was not covered by tests
}
return enrollBy;
};
Expand All @@ -628,15 +628,20 @@
* - If hasEnrollBy, we return assignments with enroll before the soonest of the two date: The subsidy expiration
* date - refund threshold OR today offset by the 90-day allocation threshold for an assignment denoted as
* isEligibleForEnrollment
* - If isLateRedemptionEnabled, we consider only the isLateEnrollmentEligible field returned by Algolia for
* - If isLateRedemptionAllowed, we consider only the isLateEnrollmentEligible field returned by Algolia for
* each run.
*
* Based on the above criteria, if isLateRedemptionAllowed is false, filter on if the course run isActive AND
* isEligibleForEnrollment
*
* We transform the assignedCourseRuns data to normalize the start and enrollby dates based on the functions
* The main purpose of the filter is to ensure that course runs for a
* course are within the enterprises LC subsidy duration
* The inclusion of the increased sensitivity reduces the chance of a specific run
* (which may be allocated but not accepted) falling outside the date range of the subsidy expiration date.
adamstankiewicz marked this conversation as resolved.
Show resolved Hide resolved
*
* Furthermore, we return assignable course runs sorted by the enrollBy date (soonest to latest). If the enrollby dates
* We transform the assignedCourseRuns data to normalize the start and enrollBy dates based on the functions
*
* Furthermore, we return assignable course runs sorted by the enrollBy date (soonest to latest). If the enrollBy dates
* are equivalent, sort by the start date.
*
* @param courseRuns
Expand All @@ -662,8 +667,8 @@
}
// Late redemption filter
if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) {
const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days');
isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff);

Check warning on line 671 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L670-L671

Added lines #L670 - L671 were not covered by tests
return isLateEnrollmentEligible && isEligibleForEnrollment;
}
// General courseware filter
Expand All @@ -672,7 +677,7 @@
// Main function that transforms the cloned course runs to the normalizedStart and normalizedEnrollBy dates
const assignableCourseRuns = clonedCourseRuns.filter(assignableCourseRunsFilter).map(courseRun => {
if (!courseRun.hasEnrollBy) {
return {

Check warning on line 680 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L680

Added line #L680 was not covered by tests
...courseRun,
start: getNormalizedStartDate(courseRun),
enrollBy: getNormalizedEnrollByDate(
Expand All @@ -687,12 +692,12 @@
enrollBy: getNormalizedEnrollByDate(courseRun.enrollBy),
};
});
// Sorts by the enrollBy date. If enrollby is equivalent, sort by start.
// Sorts by the enrollBy date. If enrollBy is equivalent, sort by start.
const sortedAssignableCourseRuns = assignableCourseRuns.sort((a, b) => {
if (a.enrollBy === b.enrollBy) {
return dayjs(a.start).unix() - dayjs(b.start).unix();

Check warning on line 698 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L698

Added line #L698 was not covered by tests
}
return a.enrollBy - b.enrollBy;

Check warning on line 700 in src/components/learner-credit-management/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/utils.js#L700

Added line #L700 was not covered by tests
});
return sortedAssignableCourseRuns;
};
Loading