Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Fix search on User Rankings and Add Ratings page #129

Merged

Conversation

vneogi199
Copy link
Contributor

@vneogi199 vneogi199 commented Feb 5, 2024

Fixes Issue #114

Closes #114

Changes proposed

  • Create fulltext index on ratings collection on username (needs to be done on appwrite in production)
  • Add react-use library to perform debouncing on search query (currently the search is done for every keypress, changed it to search only after 200ms)
  • On User Rankings page, perform search using searchParams
  • On Add Ratings page, hide search bar

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

Screenshots

Default User Rankings page
image

User Rankings page after search query vin
image

Add Ratings page (search box hidden)
image

Note to reviewers

This PR needs change to Appwrite schema as an index is added to username attribute in ratings collection.

Summary by CodeRabbit

  • New Features
    • Enhanced search functionality across the app, including keyword-based filtering for user ratings.
    • Introduced a more dynamic querying system for improved user interaction.
  • Documentation
    • Updated README to include new steps for database indexing.
  • Refactor
    • Improved search performance and user experience through debouncing input in the navigation bar.
    • Adjusted the visibility of the search feature in different components for a more intuitive user interface.

Copy link

vercel bot commented Feb 5, 2024

@vneogi199 is attempting to deploy a commit to the EddieHub Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2024

Walkthrough

Walkthrough

The recent updates to the application enhance user search functionality across various components, particularly focusing on the User Rankings page. A notable addition includes the creation of an index for improved search performance, along with modifications in the UI components to support keyword-based filtering and search debouncing. These changes aim to address a bug where user search was not functioning as expected, ensuring a smoother and more efficient user experience.

Changes

File Path Change Summary
README.md Added step to create index on ratings collection
src/app/rankings/page.js
src/components/Users.js
Enhanced search functionality by accepting searchParams and keyword for dynamic querying
src/app/rate/page.js Disabled search in SideNav
src/components/SideNav.js Improved search with debouncing and UI updates based on showSearch prop

Assessment against linked issues

Objective Addressed Explanation
Fix search bug on User Rankings page (#114)
Ensure search input debouncing for performance (#114)
Disable search where not applicable (#114)
Implement keyword-based filtering in Users component (#114)

Poem

In the code's vast garden, under a moon so bright,
A rabbit hopped with fixes, through the quiet night.
With every line and function, it mended with care,
🌟 "For users far and wide," it whispered to the air.

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c6a1375 and c0d915c.
Files ignored due to path filters (2)
  • package-lock.json is excluded by: !**/*.json
  • package.json is excluded by: !**/*.json
Files selected for processing (5)
  • README.md (1 hunks)
  • src/app/rankings/page.js (2 hunks)
  • src/app/rate/page.js (1 hunks)
  • src/components/SideNav.js (3 hunks)
  • src/components/Users.js (1 hunks)
Additional comments: 5
src/app/rankings/page.js (1)
  • 84-84: Passing keyword directly from searchParams to Users is efficient. Verify that Users component is updated to handle this prop correctly.
src/app/rate/page.js (1)
  • 31-31: Change correctly implements hiding the search bar on the Add Ratings page by setting showSearch to false.
README.md (1)
  • 64-65: Instructions for creating a fulltext index on the ratings collection are clear and necessary for search functionality. Verify subsequent step numbers are adjusted for consistency.
src/components/SideNav.js (2)
  • 75-81: The effect for navigating based on debouncedSearchKeyword is implemented correctly. Verify that this navigation behavior integrates smoothly with the rest of the application.
  • 420-449: Conditional rendering of the search bar based on showSearch prop is correctly implemented. This allows for flexible UI adjustments across different pages.

@@ -8,7 +8,7 @@ export const metadata = {
title: "User Rankings - RepoRater"
};

export default function Page() {
export default function Page({ searchParams }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure searchParams prop is validated or documented to clarify expected structure, especially the keyword property.

Comment on lines +22 to +25
export default async function Users({ keyword = "" }) {
const query = keyword
? [Query.limit(1000), Query.search("username", keyword)]
: [Query.limit(1000)];
Copy link
Contributor

Choose a reason for hiding this comment

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

Correctly implements keyword-based filtering with a default parameter and conditional query construction. Ensure keyword is sanitized before use in queries to prevent injection attacks.

Comment on lines +66 to +73
useDebounce(
() => {
setDebouncedSearchKeyword(searchKeyword);
setKeyword(searchKeyword);
},
200,
[searchKeyword],
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Correctly implements debouncing for the search input. Ensure the debounce interval of 200ms aligns with UX expectations and performance considerations.

} else {
router.push(`?keyword=${debouncedSearchKeyword}`);
}
}, [debouncedSearchKeyword, router, pathName]);
Copy link
Member

Choose a reason for hiding this comment

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

Is pathName really needed in dependency array elements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is used at line 77, though I don't see any impact keeping/removing it from the dependency array

Copy link
Member

@eddiejaoude eddiejaoude left a comment

Choose a reason for hiding this comment

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

Thank you 👍

@eddiejaoude eddiejaoude merged commit 38d7abe into EddieHubCommunity:prototype Oct 1, 2024
1 check failed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Search on User Rankings page not working
3 participants