-
Notifications
You must be signed in to change notification settings - Fork 55
feature: Implement pagination for user uploads across API and UI #342
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: dev
Are you sure you want to change the base?
feature: Implement pagination for user uploads across API and UI #342
Conversation
…d UI Signed-off-by: Yankit7039 <yankit7039@gmail.com>
Summary of ChangesHello @Yankit7039, 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 significantly enhances the application's performance and user experience by implementing comprehensive pagination for user media uploads. Previously, all media was fetched at once, leading to slow loading times and potential instability. Now, content is retrieved and displayed in manageable chunks, improving scalability and optimizing network usage for users with large numbers of uploads. Highlights
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
|
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 implements server-side pagination for user image galleries and admin user uploads. Backend changes include modifying app.py and routes/adminroutes.py to accept page and limit query parameters, validating them, and fetching paginated data using updated get_images_by_user and a new count_images_by_user function in database/userdatahandler.py. The get_images_by_user function now supports limit and offset for MongoDB queries and sorts results by creation date. On the frontend, a new Pagination React component is introduced in frontend/src/components/ui/Pagination.tsx to provide interactive pagination controls. The Gallery.tsx and UserUploads.tsx pages are updated to integrate this component, manage pagination state, and make API calls with the appropriate page and limit parameters. Review comments highlight the need to refactor duplicated pagination parameter validation logic in the backend, improve the user experience by navigating to the previous page when the last item on a non-first page is deleted, and use stable keys for ellipsis elements within the Pagination component.
Signed-off-by: Yankit7039 <yankit7039@gmail.com>
What:
This pull request introduces comprehensive pagination support for user media uploads, affecting both the backend API endpoints and the frontend UI components. It ensures that media content is fetched and displayed in manageable chunks, improving system performance and user experience.
Why:
The existing system fetched all user media uploads at once, leading to significant performance degradation, slow loading times, and potential browser instability for users with a large number of uploads. This enhancement is crucial for improving scalability, optimizing network usage, and providing a smoother user experience.
Closes #340
How:
Backend API modifications:
get_images_by_user()function indatabase/userdatahandler.pywas updated to acceptlimitandoffsetparameters, and a newcount_images_by_user()function was added./api/user/user_uploadsendpoint inapp.pyand/api/admin/user_uploads/<user_id>inroutes/adminroutes.pywere enhanced to supportpageandlimitquery parameters, returning pagination metadata (totalCount,page,limit,totalPages).created_atin descending order for consistent results.Frontend UI implementation:
currentPage,totalPages,itemsPerPage) was integrated intofrontend/src/pages/Gallery.tsxandfrontend/src/pages/admin/UserUploads.tsx.frontend/src/components/ui/Pagination.tsxcomponent was created to provide intuitive navigation (Previous/Next buttons, page numbers) and an "items per page" selector (10, 20, 50, 100).