perf: optimize API calls with total and limit query params [Backport release/0.5.z]#1141
Merged
Merged
Conversation
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 681d588)
4 tasks
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjust client-side hub API requests to control server-side total counting and limit per-page items for performance, especially when only counts are needed. Sequence diagram for optimized total-only package fetchsequenceDiagram
actor WithPackagesByLicense
participant useFetchPackages
participant HubAPI
participant children
WithPackagesByLicense->>useFetchPackages: useFetchPackages(filters, page_itemsPerPage_0, total_true)
useFetchPackages->>HubAPI: GET_packages(total_true, limit_0)
HubAPI-->>useFetchPackages: packages_response(total)
useFetchPackages-->>WithPackagesByLicense: result(total)
WithPackagesByLicense->>children: children(result_total, isFetching, fetchError)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider extracting a named constant or helper for the
itemsPerPage: 0+total: truepattern so the intent (fetch only counts) is explicit and easier to reuse without repeating magic values. - Since
totalis now being explicitly toggled betweentrueandfalsein multiple places, it may be worth centralizing default hub request options (e.g., in a factory/helper) to avoid future inconsistencies in how this flag is set.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting a named constant or helper for the `itemsPerPage: 0` + `total: true` pattern so the intent (fetch only counts) is explicit and easier to reuse without repeating magic values.
- Since `total` is now being explicitly toggled between `true` and `false` in multiple places, it may be worth centralizing default hub request options (e.g., in a factory/helper) to avoid future inconsistencies in how this flag is set.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/0.5.z #1141 +/- ##
==============================================
Coverage 51.32% 51.32%
==============================================
Files 256 256
Lines 5518 5518
Branches 1668 1668
==============================================
Hits 2832 2832
Misses 2421 2421
Partials 265 265
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backport of #1140 to
release/0.5.z.Summary by Sourcery
Optimize client API requests by adjusting pagination and total-count flags for license- and search-related queries.
Enhancements: