Sort by coursenums, filtering by department if applicable #197
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 #195
Description (What does it do?)
LEARNING_RESOURCE_SORTBY_OPTIONSto be a dict that is used to provide more user-friendly sort options to the user. For example, the user can sort bymitcoursenumberand that will actually sort bycourse.course_numbers.sort_coursenumHow can this be tested?
Temporarily modify
learning_resources_search.constants.SOURCE_EXCLUDED_FIELDSto be an empty list so you will be able to see thecourse.course_numbers.sort_coursenumvalues.Import a bunch of OCW courses, among them
21H.104J+fall_2010and a few other courses with the department_id "11" (Urban Studies and Planning), plus some other departments.Go to this url to sort by course number, filtered by department:
http://localhost:8063/api/v1/learning_resources_search/?department=11&sortby=mitcoursenumber
Verify the results are in ascending order by
course.course_numbers.sort_coursenumfor the respective department ("11"). The course mentioned above,21H.104J+fall_2010, has a cross-listed id within that department of "11.015J" so it should appear in the correct position relative to the other courses imported from that department.Go to this url to sort by course number, unfiltered by department:
http://localhost:8063/api/v1/learning_resources_search/?sortby=mitcoursenumber
Verify the results are sorted by
course.course_numbers.sort_coursenumwherelisting_type=primary, and not by any cross-listed numbers.Check that the schema documentation for this endpoint shows some user-friendly sort options:
I did not try to make the departments parameter schema documentation more user-friendly in this PR, leaving that for a future one because the use of a custom field class (
StringArrayField) for that parameter makes it seem at first glance that doing so might be somewhat involved.