-
Notifications
You must be signed in to change notification settings - Fork 3
fix non-lexicographical ordering in org dashboard programs / program collections #2523
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
Conversation
… program, because the API does not respect this order
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.
👍
const rawCourses = | ||
courses.data?.results.sort((a, b) => { | ||
return firstCourseIds.indexOf(a.id) - firstCourseIds.indexOf(b.id) | ||
}) ?? [] |
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.
As far as I can tell, program collections have no ordering of the associated programs.
So if the UAI vertical modules on prod look correct, great, but I don't think that's guaranteed by anything, is it?
I.e., there's (currently) no way in wagtail / mitxonline admin to set the order of these programs, is there?

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.
This is a good point. I suppose it would preserve whatever ordering is passed back from the API though, nonetheless.
queries: programIds.map((programId) => ({ | ||
...programsQueries.programsList({ id: programId, org_id: orgId }), | ||
queryKey: [ | ||
...programsQueries.programsList({ id: programId, org_id: orgId }) | ||
.queryKey, | ||
], | ||
})), |
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.
This can just be
queries: programIds.map((programId) =>
programsQueries.programsList({ id: programId, org_id: orgId }),
)
useProgramCollectionCourses(collection.programIds, orgId) | ||
const firstCourseIds = programsWithCourses | ||
.map((p) => p?.program.courseIds[0]) | ||
.filter((id): id is number => id !== undefined) |
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.
This is another example of something TS ^5.5 will catch automatically, no need for the id is number
part.
…collections (#2523) * Sort program / program collection courses by the order of id's on the program, because the API does not respect this order * remove unnecessary spread * remove unnecessary expansion
…collections (#2523) * Sort program / program collection courses by the order of id's on the program, because the API does not respect this order * remove unnecessary spread * remove unnecessary expansion
…collections (#2523) * Sort program / program collection courses by the order of id's on the program, because the API does not respect this order * remove unnecessary spread * remove unnecessary expansion
* Release 0.43.1 * Release date for 0.43.1 * canvas: citation urls for html content (#2521) * updates to support urls for non-file items * adding canvas type * working urls for assignments and pages * adding title to contentfile and test for urls * update test * titles for embedded pages * fix non-lexicographical ordering in org dashboard programs / program collections (#2523) * Sort program / program collection courses by the order of id's on the program, because the API does not respect this order * remove unnecessary spread * remove unnecessary expansion * removing special cased sloan page scraper --------- Co-authored-by: Doof <mitx-devops@mit.edu> Co-authored-by: Carey P Gumaer <gumaerc@mit.edu>
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/8626
Description (What does it do?)
This PR fixes a bug with the ordering of courses within programs and program collections. The courses API endpoint in mitxonline does not respect the order that you pass ID's in when making a query for the detail of multiple courses. The courses end up being ordered alphabetically in a non-lexicographical manner. This PR does re-ordering on the frontend of the results so that the order matches the order of the ID's in the
courses
array on the program API response. The querying of the courses in a program collection has also been optimized to only use one query for all the first courses in each program in the collection, rather than making one query per collection.How can this be tested?
In order to test this, you need a basic installation of
mitxonline
up and running with example data in it. You may be able to skip one or more steps if you have already done them:hosts
redirects for the following domains, replacing the example IP with your local IP address (Google how to get this if unsure, mine is 192.168.1.50)mitxonline
: https://github.com/mitodl/mitxonline.env
file with the following values:mitxonline
withdocker compose up --build -d
docker compose exec web ./manage.py promote_user promote --superuser --email admin@odl.local
docker compose exec web ./manage.py populate_course_data
pants docs ::
dist/sphinx/index.html
, read the section on generating a B2B organization / contract and create one, adding all 10 of the test coursesProgram
and add all of the courses to the program that are included in your B2B org, making sure to mark the program as "live"mit-learn
, we need to set some env variables:enrollment-dashboard
andmitlearn-organization-dashboard
feature flags for all usersMIT Learn