Load all pages of course results for programs in the organization dashboard #2490
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/8312
Description (What does it do?)
The courses API in MITx Online is paginated. So, if a program is displayed on a learner's organization tab that happens to contain more than a single page of courses (so, 10), the learner will only see the first page of courses in the list.
This PR adds some code to switch over the loading to use an infinite query, which is aware of paginated result sets, and then to eagerly load the remaining pages of results for the program's courses if it happens to have more than 10 in it.
How can this be tested?
You will need Learn set up as well as MITx Online and ideally edX.
Set up a program that has more than 10 courses in it. (For testing, I set up a program with 14 courses to match the "all UAI courses" program in production.) Then, add the program to a contract, and add your test user to the contract.
Load the organization tab. You should see the program in it. You should see all of the courses within the program. (On the
main
branch, you should only see the first 10 courses.)Additional Context
The component pulls a specific list of courses based on what's in the program. So, eager loading the courses shouldn't be a problem, but if we end up with a bunch of programs that have lots of courses in them, we may want to revisit how we display programs and courses in the org tab.