-
Notifications
You must be signed in to change notification settings - Fork 5
⚡ Bolt: server-side filtering for user games #386
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
base: main
Are you sure you want to change the base?
⚡ Bolt: server-side filtering for user games #386
Conversation
Optimizes the fetching of user games by implementing server-side filtering for game statuses. This reduces the payload size for the Library and Wishlist pages, which previously fetched all games and filtered them on the client. - Updates `IStorage` and implementations to support `statuses` array in `getUserGames`. - Updates `GET /api/games` to parse `status` query parameter. - Updates `LibraryPage` and `WishlistPage` to request specific statuses. - Ensures backward compatibility for existing callers. Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @Doezer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors how user game data is fetched and filtered, moving the filtering logic from the client-side to the server-side for the Library and Wishlist pages. This change aims to optimize performance by reducing the payload size for API requests, particularly beneficial for users with extensive game collections, and ensures that only relevant data is transferred to the client. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Code Review
This pull request effectively implements server-side filtering for user games, which is a significant performance enhancement. The frontend pages are correctly updated to leverage this new API feature, reducing data transfer and client-side processing. The backend logic in server/routes.ts and server/storage.ts correctly implements the filtering, and the tests are updated to match. I have one suggestion to improve the robustness of the query parameter parsing on the server.
| let statuses: string[] | undefined; | ||
| if (typeof status === "string" && status.trim().length > 0) { | ||
| statuses = status | ||
| .split(",") | ||
| .map((s) => s.trim()) | ||
| .filter((s) => s.length > 0); | ||
| } |
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.
The current implementation for parsing the status query parameter only handles a single comma-separated string. It would be more robust to handle cases where statuses are provided as multiple query parameters (e.g., ?status=owned&status=completed), which Express parses as an array. This can be generalized to handle both strings and arrays of strings, including comma-separated values within them.
let statuses: string[] | undefined;
if (status) {
const statusValues = Array.isArray(status) ? status : [status];
statuses = statusValues
.flatMap((s) => String(s).split(","))
.map((s) => s.trim())
.filter((s) => s.length > 0);
if (statuses.length === 0) {
statuses = undefined;
}
}Optimizes the fetching of user games by implementing server-side filtering for game statuses. This reduces the payload size for the Library and Wishlist pages. - Updates `IStorage` and implementations to support `statuses` array in `getUserGames`. - Updates `GET /api/games` to parse `status` query parameter. - Updates `LibraryPage` and `WishlistPage` to request specific statuses. - Adds comprehensive tests for storage implementations and API routes. Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com>
⚡ Bolt: Implement server-side filtering for user games
💡 What: Added support for filtering user games by status on the backend, and updated the frontend to request only the necessary games for the Library and Wishlist pages.
🎯 Why: The Library and Wishlist pages were fetching all user games (including hidden and wanted games for Library, and owned games for Wishlist) and filtering them on the client. This resulted in unnecessary data transfer and processing, especially for users with large collections.
📊 Impact: Significantly reduces the JSON payload size for
GET /api/gameswhen used in Library and Wishlist contexts. For a user with 1000 wanted games and 50 owned games, the Library page load payload is reduced by ~95%.🔬 Measurement:
GET /api/games?status=owned,completed,downloadingshould return only relevant games.GET /api/games?status=wantedshould return only wanted games.npm test server/__tests__/api_routes.test.ts.PR created automatically by Jules for task 3379833437833090869 started by @Doezer