Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Fix/pagination#352

Merged
abdheshnayak merged 7 commits into
release-v1.0.7from
fix/pagination
Jul 18, 2024
Merged

Fix/pagination#352
abdheshnayak merged 7 commits into
release-v1.0.7from
fix/pagination

Conversation

@abdheshnayak
Copy link
Copy Markdown
Contributor

@abdheshnayak abdheshnayak commented Jul 18, 2024

  • fixed issue with sorting and cursor-pagination.

Summary by Sourcery

This pull request fixes issues with sorting and cursor-based pagination in the MongoDB repository. It enhances the pagination logic to dynamically determine the cursor key and correctly handle both ascending and descending sort directions. Additionally, new dependencies were added to support these changes.

  • Bug Fixes:
    • Resolved issues with sorting and cursor-based pagination in MongoDB repository.
  • Enhancements:
    • Improved cursor-based pagination by dynamically determining the cursor key based on the order by field.
    • Enhanced pagination logic to handle both ascending and descending sort directions correctly.
  • Build:
    • Added new dependencies: github.com/PaesslerAG/jsonpath and github.com/PaesslerAG/gval.

@abdheshnayak abdheshnayak merged commit b2b93da into release-v1.0.7 Jul 18, 2024
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 18, 2024

Reviewer's Guide by Sourcery

This pull request addresses issues with sorting and cursor-based pagination in the MongoDB repository implementation. The changes include refactoring the pagination logic to support sorting by different fields, updating the 'cursorToStruct' function to return additional data, and modifying the 'Find' and 'FindPaginated' methods to handle these changes. New dependencies 'github.com/PaesslerAG/jsonpath' and 'github.com/PaesslerAG/gval' were added to support the new functionality.

File-Level Changes

Files Changes
pkg/repos/db-repo-mongo.go Refactored pagination logic to support sorting by different fields and fixed cursor-based pagination issues.
go.mod Added new dependencies required for the updated pagination logic.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@abdheshnayak abdheshnayak deleted the fix/pagination branch July 18, 2024 12:19
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @abdheshnayak - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

}

func cursorToStruct[T any](ctx context.Context, curr *mongo.Cursor) ([]T, error) {
func cursorToStruct[T any](ctx context.Context, curr *mongo.Cursor) ([]T, []map[string]any, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider renaming the second return value for clarity

The second return value []map[string]any could be renamed to something more descriptive, like rawResults, to make the code more readable and self-explanatory.

abdheshnayak added a commit that referenced this pull request Nov 5, 2024
* 🐛 Fixed cursor-pagination with sorting

---------

Co-authored-by: Karthik <karthik@kloudlite.io>
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.

Sort is not working with pagination on backend Pagenation on Frontend

2 participants