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

Fall back when no recommended course version #52919

Merged
merged 4 commits into from
Jul 24, 2023
Merged

Conversation

rshipp
Copy link
Contributor

@rshipp rshipp commented Jul 20, 2023

When there are no recommended course versions for a given selection, the section setup flow was raising an exception and not allowing certain courses to be assigned. Instead, we should fall back to the most recent stable course version. (Thanks Bethany for knowing what that behavior should be.)

image

Links

@rshipp rshipp marked this pull request as ready for review July 20, 2023 21:25
@rshipp rshipp requested a review from a team July 20, 2023 21:25
Copy link
Contributor

@hannahbergam hannahbergam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super important work- thank you for cleaning it up!! Only two (related) comments.

const stableVersions = Object.values(courseVersions).filter(
version => version.is_stable
);
courseVersionId = stableVersions[stableVersions.length - 1]?.id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know for sure that these will always be in chronological order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, no, that was just an assumption I made 😅 I'll check the api, and see if I need to sort these by something instead.

Copy link
Contributor Author

@rshipp rshipp Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the API isn't sorting, and just returns things in whatever order they come from sql. which should typically be oldest things first, but there's no guarantee. it looks like the key is consistently a "version year", so I'm sorting by that instead. unless you know of any exceptions to that rule?

courseOfferings: noRecommendedVersionsOfferings,
});

const radio = wrapper.find('input');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this test! The only thing I can think of would be to add one more stable version of a different year to ensure this is grabbing the most recent one.

Copy link
Contributor

@hannahbergam hannahbergam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! I *think your instincts were right that it's sorted somewhere else, but I appreciate this explicitly residing here in case we ever change the display sorting

@rshipp rshipp merged commit 47a82a2 into staging Jul 24, 2023
2 checks passed
@rshipp rshipp deleted the courseversion-fallback branch July 24, 2023 17:31
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.

None yet

2 participants