Skip to content

Sorting with total students#572

Merged
TyHil merged 7 commits intodevelopfrom
sorting-with-total-students
Feb 24, 2026
Merged

Sorting with total students#572
TyHil merged 7 commits intodevelopfrom
sorting-with-total-students

Conversation

@PyroSh0ck
Copy link
Contributor

Overview

Added feature to sum up total students per term for a course as well as total students per professor for use in sorting autocomplete results by relevancy.

What Changed

GenerateAutocompleteGraph.ts was modified substantially, including changes to the addCourse and addProfessor functions to add a totalStudents attribute to the node containing the payload in the radix tree. Likewise, terms are compared based on student count (not recency as this had unpredictable results (see commit 31b163b). The route.ts file for the autocomplete api contains a slight modification that sorts the results from the radix tree in order of student count (with priority given to professors over courses).

Other Notes

Many of the courses still do not have totalStudent data, which makes them impossible to sort and they are placed at the bottom. In the future, they should be sorted by the year in which they are meant to be taken (so CS 6V98 should be placed above CS 8V99, which is not the case currently). Likewise, I believe we should be able to get the data for students from elsewhere if its not available from where we are currently retrieving it (possibly coursebook?).

Modified the autocompleteGraph.ts file to count students per section per course and add that to the course node attribute via addCourse function. Likewise, modified addProf function to update the professor node by adding its students to the students retrieved by section. Lastly, added new datatype SearchQueryWithTotalStudents
Added the sorting for autocomplete results by the total student count for the course or the professor. Sorting was done in a descending order, with priority given to courses over professors (to match the current format). A modification was made to generateAutocompleteGraph, where the uniqueSetKey (key to a set to avoid duplicate professors in the same section) was moved inside of the if statement, to avoid adding an empty professor as a key.
Modified the aggregation of totalStudents. Previously the total students for a course were being summed up across all of the different terms. Now, only the term with the most students (which will usually be the second most recent term) will be used for sorting autocomplete results. The most recent term isn't used as the data retrieval seems to not be available immediately after the succeeding term begins. The use of the most recent term frequently results in incorrect and unpredictable data, and hence was avoided. Sorting via professors was left untouched as the resulting data was sensible.
@PyroSh0ck PyroSh0ck requested a review from egsch as a code owner February 11, 2026 00:50
@vercel
Copy link

vercel bot commented Feb 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
utd-trends Ready Ready Preview, Comment Feb 24, 2026 4:55am

Request Review

Copy link
Member

@TyHil TyHil 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 cool. I think a good way to see the impact, just to note for others, is to type "13" into the search bar and see how much more relevant the results are.

I'm gonna wait to review the generateAutocompleteGraph file until you go back to summing all the sections instead of taking the max section, as we discussed in dm. So this is just some changes to make to the other files

Moved the sorting for results from route.ts to autocomplete.ts. Also reverted the addition of "tsx" to package.json and package-lock.json. Reverted the unnecessary changes to Searchbar.tsx. Refactored generateAutocompleteGraph.tsx file so that it sums all the sections instead of taking the max section, so it can be reviewed.
Removed SessionNameAndStudents as it was no longer in use and triggered ESLint warnings.
Copy link
Member

@TyHil TyHil left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@egsch if you'd give it the final look

Copy link
Contributor

@egsch egsch left a comment

Choose a reason for hiding this comment

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

This looks great, thank you @PyroSh0ck ! It's a big improvement testing this version against the previous suggestions.

The comment in generateAutocompleteGraph.ts has been removed.
@TyHil TyHil merged commit 7e74c4d into develop Feb 24, 2026
3 checks passed
@TyHil TyHil deleted the sorting-with-total-students branch February 24, 2026 05:06
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.

3 participants