Skip to content
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

Search Results #446

Merged
merged 28 commits into from
May 6, 2024
Merged

Search Results #446

merged 28 commits into from
May 6, 2024

Conversation

jacquelinecai
Copy link
Contributor

@jacquelinecai jacquelinecai commented May 5, 2024

Summary

This PR works on the Search/Results feature.

PR Type

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Mobile + Desktop Screenshots & Recordings

Fixed bug for queries with dashes:
image

QA - Test Plan

Running Search.test.ts

Breaking Changes & Notes

  • Improved search/results time on frontend
  • Added new endpoint to separate search and results
  • Worked on parallelism issue with search queries

Added to documentation?

  • πŸ“œ README.md
  • πŸ““ notion
  • πŸ• ...
  • πŸ“• ...
  • πŸ™… no documentation needed

What GIF represents this PR?

gif

@jacquelinecai jacquelinecai requested a review from a team as a code owner May 5, 2024 23:48
@dti-github-bot
Copy link
Member

dti-github-bot commented May 5, 2024

[diff-counting] Significant lines: 1993. This diff might be too big! Developer leads are invited to review the code.

Copy link
Contributor

@leihelen leihelen left a comment

Choose a reason for hiding this comment

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

Everything looks great and it's super helpful how you were able to fix so many bugs with the current search algorithm! I also think adding the new results endpoint that is separate from the search endpoint really improves the efficiency and clarity of the search algorithm so good job with that!

For the course results endpoint maybe you can also log the error in the console log as well to make it easier to understand the errors. You could also process the search query string in sanitizeQuery with query.replace(/+/g, ' ').toLowerCase() instead in case there are multiple occurrences not just one. Something else to maybe consider to make it more efficient is parallelizing searchCoursesByProfessor and searchCourses rather than running them sequentially.

Copy link
Contributor

@qiandrewj qiandrewj left a comment

Choose a reason for hiding this comment

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

Jacqueline, this is great work, and a really challenging task you've been given! I wasn't able to fully understand all of the changes to the search algorithm at work, but I think that your edits for processing speed by cutting down on the number of returned results and also fixing the parallelism issue is great. I left some comments and questions, but amazing job!

@@ -21,27 +20,28 @@ const fullCourseSearch = async ({ search }: SearchQueryType) => {
const query = search.getQuery();
let fullSearch = new Set(); // set to ensure no duplicate courses

if (query !== undefined && query !== '') {
// checks query after at least 2 characters to speed up search
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a smart solution, since there isn't much information to search for with just one character. It can help improve speed without actually affecting the user experience

return sorted.slice(0, 5);
}

if (sorted && searchType === "results" && sorted.length > 200) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are "results" search types being used for if they provide much more information than we can display?

} catch (e) {
return null;
}
};

export const searchCoursesByProfessor = async ({ search }: SearchQueryType) => {
export const searchCoursesByProfessor = async ({ search }: SearchQueryType, searchType: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where you add searchType here, which can either be "search" for 5 results or "results" for <200, would it be easier to just migrate to all "search"?

Copy link
Collaborator

@wizhaaa wizhaaa left a comment

Choose a reason for hiding this comment

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

Awesome work!!!! Glad we were able to fix most of the issues regarding the search bar.

Hopefully we can potentially work a little bit of the search results page and other minor bugs in a future PR.

Note: Most of issues were discussed in person - documented at https://www.notion.so/Search-Production-Bug-f05d0f1e00714b909ed75aed02dac09c?pvs=4

@jacquelinecai jacquelinecai merged commit 9fae7cc into master May 6, 2024
4 checks passed
@jacquelinecai jacquelinecai deleted the jacqueline/search-results branch May 6, 2024 22:19
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.

None yet

5 participants