Skip to content

Conversation

@Yankit7039
Copy link

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:

  1. Backend API modifications:

    • The get_images_by_user() function in database/userdatahandler.py was updated to accept limit and offset parameters, and a new count_images_by_user() function was added.
    • The /api/user/user_uploads endpoint in app.py and /api/admin/user_uploads/<user_id> in routes/adminroutes.py were enhanced to support page and limit query parameters, returning pagination metadata (totalCount, page, limit, totalPages).
    • API responses now include sorting by created_at in descending order for consistent results.
  2. Frontend UI implementation:

    • Pagination state management (currentPage, totalPages, itemsPerPage) was integrated into frontend/src/pages/Gallery.tsx and frontend/src/pages/admin/UserUploads.tsx.
    • A new, reusable frontend/src/components/ui/Pagination.tsx component was created to provide intuitive navigation (Previous/Next buttons, page numbers) and an "items per page" selector (10, 20, 50, 100).
    • API calls from the frontend now include the appropriate pagination parameters.

…d UI

Signed-off-by: Yankit7039 <yankit7039@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Backend API Pagination: The backend API endpoints /api/user/user_uploads and /api/admin/user_uploads/<user_id> now support page and limit query parameters. They return paginated results along with metadata such as totalCount, page, limit, and totalPages. Results are consistently sorted by created_at in descending order.
  • Database Layer Enhancements: The get_images_by_user() function in database/userdatahandler.py was updated to accept limit and offset parameters for efficient data retrieval. A new count_images_by_user() function was added to facilitate total count calculation for pagination.
  • Reusable Frontend Pagination Component: A new, reusable Pagination.tsx component was created in the frontend. This component provides intuitive navigation with previous/next buttons, page numbers, and an 'items per page' selector (10, 20, 50, 100).
  • Frontend UI Integration: Pagination state management (currentPage, totalPages, itemsPerPage) has been integrated into frontend/src/pages/Gallery.tsx and frontend/src/pages/admin/UserUploads.tsx. Frontend API calls now include the appropriate pagination parameters, and the UI updates dynamically based on the paginated data.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Yankit7039 added a commit to Yankit7039/Beehive that referenced this pull request Dec 13, 2025
Signed-off-by: Yankit7039 <yankit7039@gmail.com>
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.

2 participants