-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add best match sorting #1830
Add best match sorting #1830
Conversation
WalkthroughThe changes introduce a new enumeration value, Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
src/repositories/projectRepository.ts (1)
255-256
: Consider adding a TODO comment or removing the emptycase
block.The new
case
statement forSortingField.BestMatch
has been added, but it lacks an implementation. This empty block might cause confusion.Suggestions:
- Add a TODO comment inside the empty
case
block to indicate that the implementation for the "Best Match" sorting functionality is pending. This will help track the remaining work.- Alternatively, consider removing the empty
case
block entirely until the implementation is ready to avoid any potential confusion or misinterpretation.Example:
case SortingField.BestMatch: + // TODO: Implement the logic for sorting projects by the "Best Match" criterion. break;
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/entities/project.ts (1 hunks)
- src/repositories/projectRepository.ts (1 hunks)
- src/resolvers/projectResolver.ts (1 hunks)
Additional comments not posted (2)
src/resolvers/projectResolver.ts (2)
331-337
: Prioritize projects with matching titles in search results.The added
SELECT
statement uses aCASE
expression to assign a priority value to each project based on whether its title matches the search term. Projects with matching titles are assigned a priority of 1, while non-matches are assigned a priority of 2. This allows the search results to prioritize projects with more relevant titles.
340-346
: Order search results by title match priority.The modified
WHERE
clause adds a new condition to check if the project title matches the search term using the%>
operator. This condition is combined with the existing conditions for matching the project description and impact location.The search results are then ordered by the
title_priority
alias in ascending order. This ensures that projects with matching titles (priority 1) appear before non-matches (priority 2) in the search results.Finally, the
searchTerm
parameter is set for the query to be used in theWHERE
clause conditions.
@@ -77,6 +77,7 @@ export enum SortingField { | |||
InstantBoosting = 'InstantBoosting', | |||
ActiveQfRoundRaisedFunds = 'ActiveQfRoundRaisedFunds', | |||
EstimatedMatching = 'EstimatedMatching', | |||
BestMatch = 'BestMatch', |
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.
Tip
Codebase Verification
Empty implementation for BestMatch
sorting option
The BestMatch
enum value has been added, but its implementation in src/repositories/projectRepository.ts
is empty. This may lead to unexpected behavior when this sorting option is selected.
- In
src/repositories/projectRepository.ts
, the case forSortingField.BestMatch
only contains abreak
statement, lacking any sorting logic.
Please implement the proper sorting logic for the BestMatch
option. Review the intended behavior of this sorting option and update the switch case accordingly.
Analysis chain
LGTM!
The addition of the BestMatch
enum value to the SortingField
enum looks good. It expands the sorting options available in the application without introducing any apparent issues or inconsistencies.
To ensure the new sorting option is being utilized correctly and produces the expected results, please verify its implementation and usage in the relevant parts of the codebase. You can use the following script to search for references to BestMatch
:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the implementation and usage of the `BestMatch` sorting option.
# Test: Search for references to `BestMatch` in TypeScript files.
# Expect: Occurrences in the relevant sorting implementations and usages.
rg --type ts $'BestMatch' -A 5
Length of output: 664
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.
Thanks @MohammadPCh LGTM
Summary by CodeRabbit
New Features
Bug Fixes
Documentation