Skip to content

feat: add some pagination options #980

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

Open
wants to merge 1 commit into
base: refacto/pagination-system
Choose a base branch
from

Conversation

gfyrag
Copy link
Contributor

@gfyrag gfyrag commented Jun 20, 2025

Fixes LX-62

@gfyrag gfyrag requested a review from a team as a code owner June 20, 2025 09:14
Copy link

coderabbitai bot commented Jun 20, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • release/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/add-pagination-options

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

cursor[bot]

This comment was marked as outdated.

@gfyrag gfyrag force-pushed the feat/add-pagination-options branch from 0545e6a to ffcd47d Compare June 20, 2025 10:11
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 69.81132% with 16 lines in your changes missing coverage. Please review.

Project coverage is 82.89%. Comparing base (858712a) to head (ffcd47d).

Files with missing lines Patch % Lines
internal/storage/common/errors.go 0.00% 9 Missing ⚠️
internal/storage/common/resource.go 0.00% 2 Missing and 1 partial ⚠️
internal/api/v2/common.go 81.81% 2 Missing ⚠️
internal/api/v2/controllers_volumes.go 0.00% 1 Missing ⚠️
internal/controller/ledger/controller_default.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           refacto/pagination-system     #980      +/-   ##
=============================================================
- Coverage                      82.92%   82.89%   -0.04%     
=============================================================
  Files                            145      145              
  Lines                           8199     8219      +20     
=============================================================
+ Hits                            6799     6813      +14     
- Misses                          1075     1081       +6     
  Partials                         325      325              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug

The UpdateAccountsMetadata method now accepts a time.Time parameter (at) to set FirstUsage. This introduces two issues with the SQL update logic for first_usage:

  1. When time.Time{} (zero time, January 1, year 1) is passed for at (e.g., in test calls or metadata-only updates), the case when excluded.first_usage < accounts.first_usage then excluded.first_usage else accounts.first_usage end condition incorrectly sets first_usage to zero time, as zero time is always earlier than any valid timestamp. This can overwrite existing correct first_usage values.
  2. The same SQL logic fails to correctly set first_usage when accounts.first_usage is NULL and excluded.first_usage has a real timestamp. The comparison real_date < NULL evaluates to NULL (unknown), causing the CASE statement to retain the NULL value.
    These issues lead to first_usage being corrupted or not set properly, preventing accurate tracking of account first usage.

internal/storage/ledger/accounts.go#L24-L62

func (store *Store) UpdateAccountsMetadata(ctx context.Context, m map[string]metadata.Metadata, at time.Time) error {
_, err := tracing.TraceWithMetric(
ctx,
"UpdateAccountsMetadata",
store.tracer,
store.updateAccountsMetadataHistogram,
tracing.NoResult(func(ctx context.Context) error {
span := trace.SpanFromContext(ctx)
span.SetAttributes(attribute.StringSlice("accounts", Keys(m)))
type AccountWithLedger struct {
ledger.Account `bun:",extend"`
Ledger string `bun:"ledger,type:varchar"`
AddressArray []string `bun:"address_array,type:jsonb"`
}
accounts := make([]AccountWithLedger, 0)
for account, accountMetadata := range m {
accounts = append(accounts, AccountWithLedger{
Ledger: store.ledger.Name,
Account: ledger.Account{
Address: account,
Metadata: accountMetadata,
FirstUsage: at,
},
AddressArray: strings.Split(account, ":"),
})
}
ret, err := store.db.NewInsert().
Model(&accounts).
ModelTableExpr(store.GetPrefixedRelationName("accounts")).
On("conflict (ledger, address) do update").
Set("metadata = accounts.metadata || excluded.metadata").
Set("updated_at = excluded.updated_at").
Set("first_usage = case when excluded.first_usage < accounts.first_usage then excluded.first_usage else accounts.first_usage end").
Where("not accounts.metadata @> excluded.metadata").

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

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.

3 participants