Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
TyHil
requested changes
Feb 11, 2026
Member
TyHil
left a comment
There was a problem hiding this comment.
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.
egsch
approved these changes
Feb 24, 2026
Contributor
egsch
left a comment
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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?).