Skip to content
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

feat(core): Massive update to Pagination + update Backend functions #168

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

GeekMasher
Copy link
Contributor

This pull request introduces a new pagination feature to the geekorm library, along with several associated changes to support this functionality. The main changes include adding a new Pagination struct, modifying existing methods to support pagination, and updating the documentation and examples to reflect these changes.

Pagination Feature:

  • New Pagination Example:

    • Added a new example pagination.rs demonstrating how to use the chrono crate with geekorm for pagination. (examples/pagination.rs)
  • Pagination Struct and Methods:

    • Introduced a new Pagination struct in geekorm-core/src/queries/pagination.rs to handle pagination logic. (geekorm-core/src/queries/pagination.rs)
    • Added methods paginate, page, and all to fetch paginated results in geekorm-core/src/backends/mod.rs. (geekorm-core/src/backends/mod.rs) [1] [2]
    • Deprecated the fetch_all method in favor of the new all method. (geekorm-core/src/backends/mod.rs)

Code Refactoring:

  • Renaming and Refactoring:
    • Renamed Pagination to Page in geekorm-core/src/queries/pages.rs and updated related methods and documentation. (geekorm-core/src/queries/pages.rs) [1] [2] [3] [4] [5]
    • Updated imports and usage of Page in various files. (geekorm-core/src/lib.rs, geekorm-core/src/queries/builder.rs, geekorm-core/src/queries/mod.rs, src/lib.rs) [1] [2] [3] [4] [5]

Error Handling:

  • Pagination Error:
    • Added a new PaginationError variant to the Error enum to handle pagination-specific errors. (geekorm-core/src/error.rs)

Example and Documentation:

  • Cargo.toml Update:
    • Added the new pagination example to Cargo.toml under the examples section. (Cargo.toml)

These changes collectively enhance the geekorm library by adding robust pagination support, improving code organization, and ensuring better error handling.

@GeekMasher GeekMasher requested a review from Copilot January 10, 2025 23:30

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 10 changed files in this pull request and generated no comments.

Files not reviewed (5)
  • geekorm-core/src/queries/builder.rs: Evaluated as low risk
  • src/lib.rs: Evaluated as low risk
  • geekorm-core/src/lib.rs: Evaluated as low risk
  • geekorm-core/src/error.rs: Evaluated as low risk
  • geekorm-core/src/queries/mod.rs: Evaluated as low risk
Comments suppressed due to low confidence (4)

geekorm-core/src/queries/pages.rs:132

  • Using u32::MAX as the default page value is unconventional and could lead to confusion or unintended behavior. Consider using a more conventional default value, such as 0.
page: u32::MAX,

geekorm-core/src/backends/mod.rs:123

  • Ensure that the new 'all' method is covered by tests.
async fn all(connection: &'a C) -> Result<Vec<Self>, crate::Error> {

geekorm-core/src/backends/mod.rs:134

  • Ensure that the new 'page' method is covered by tests.
async fn page(connection: &'a C, page: &crate::Page) -> Result<Vec<Self>, crate::Error> {

geekorm-core/src/backends/mod.rs:149

  • Ensure that the new 'paginate' method is covered by tests.
async fn paginate(connection: &'a C) -> Result<crate::Pagination<Self>, crate::Error> {

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

@GeekMasher GeekMasher enabled auto-merge (rebase) January 10, 2025 23:40
@GeekMasher GeekMasher merged commit eb11ffd into main Jan 10, 2025
10 checks passed
@GeekMasher GeekMasher deleted the pagination-updates branch January 10, 2025 23:49
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.

1 participant