feat: add RankingLimit filter with all/limit query params to cap or remove ranking row limits - #5624
Merged
akshaydeo merged 5 commits intoJul 28, 2026
Conversation
Contributor
📝 WalkthroughWalkthroughRanking queries now accept caller-controlled limits through HTTP filters. The effective limit is applied to RDB aggregations and PostgreSQL matview queries, with tests covering default, explicit, oversized, and uncapped ranking requests. ChangesRanking limit propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant HTTPClient
participant RankingHandlers
participant RDBLogStore
participant RankingQuery
HTTPClient->>RankingHandlers: Send all or limit parameters
RankingHandlers->>RDBLogStore: Invoke ranking endpoint with SearchFilters
RDBLogStore->>RankingQuery: Apply effective ranking limit
RankingQuery-->>RDBLogStore: Return capped or uncapped rankings
RDBLogStore-->>RankingHandlers: Return ranking results
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This was referenced Jul 28, 2026
Merged
Contributor
Author
Merged
18 tasks
RankingLimit filter with all/limit query params to cap or remove ranking row limits
impoiler
force-pushed
the
07-28-fix_loading_flickering_for_empty_state
branch
from
July 28, 2026 15:19
1697ed0 to
45e73e3
Compare
impoiler
force-pushed
the
07-28-fix_dashboard_rankings_limit_support_backend
branch
from
July 28, 2026 15:19
a1086b9 to
9e5adbb
Compare
impoiler
marked this pull request as ready for review
July 28, 2026 15:24
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@framework/logstore/rdb_ranking_limit_test.go`:
- Around line 73-88: Update TestGetModelRankingsRespectsRankingLimit and its
setup so seeded rows use distinct model values while retaining valid provider
data, then assert that the unlimited query returns all seeded rankings and
RankingLimit=1 returns exactly one. Ensure the assertions distinguish uncapped
from capped behavior rather than merely verifying non-empty results.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: df5ad2d3-4dda-44cc-a6f8-375da9bc4136
📒 Files selected for processing (5)
framework/logstore/matviews.goframework/logstore/rdb.goframework/logstore/rdb_ranking_limit_test.goframework/logstore/tables.gotransports/bifrost-http/handlers/logging.go
18 tasks
Contributor
Merge activity
|
akshaydeo
changed the base branch from
07-28-fix_loading_flickering_for_empty_state
to
graphite-base/5624
July 28, 2026 20:51
akshaydeo
dismissed
coderabbitai[bot]’s stale review
July 28, 2026 20:54
The base branch was changed.
akhsaul
pushed a commit
to akhsaul/bifrost
that referenced
this pull request
Aug 27, 2026
…p or remove ranking row limits (maximhq#5624) ## Summary Ranking queries (`GetModelRankings`, `GetUserRankings`, `GetDimensionRankings`) were previously hard-coded to return at most `defaultMaxRankingsLimit` (100) rows with no way for callers to override that cap. This made it impossible for the dashboard export to retrieve the full ranked list. This PR introduces a `RankingLimit` field on `SearchFilters` and exposes `all` / `limit` query parameters on the ranking HTTP endpoints so callers can request a custom cap or an uncapped result. ## Changes - Added `RankingLimit *int` to `SearchFilters` and an `EffectiveRankingLimit(defaultLimit int) int` helper that resolves `nil` → store default, `<= 0` → no cap, and `> 0` → explicit cap. - Extracted a shared `applyRankingLimit(q *gorm.DB, filters SearchFilters) *gorm.DB` helper in `rdb.go` that replaces the inline `.Limit(defaultMaxRankingsLimit)` calls in `GetModelRankings`, `GetUserRankings`, and `GetDimensionRankings`. - Applied the same `applyRankingLimit` pattern to the materialized-view-backed ranking paths in `matviews.go`, which previously had no limit at all. - Added `ParseRankingLimit` in the HTTP handler layer to parse `all=true` (uncapped, for exports) and `limit=<n>` (explicit positive cap) query parameters, writing a 400 on invalid input. - Wired `ParseRankingLimit` into `getModelRankings`, `getDimensionRankings`, and `getDashboard`. - Added `rdb_ranking_limit_test.go` with an in-memory SQLite store that seeds more rows than the default cap and verifies all four cases: default cap, explicit limit, limit above row count, and `all=true`. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [x] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go test ./framework/logstore/... -run TestGetDimensionRankingsRespectsRankingLimit go test ./framework/logstore/... -run TestGetModelRankingsRespectsRankingLimit go test ./... ``` To exercise the HTTP layer manually, call a ranking endpoint with the new parameters: ```sh # Return at most 10 rows GET /api/logs/rankings?limit=10 # Return every ranked entity (export use-case) GET /api/logs/rankings?all=true # Invalid inputs return HTTP 400 GET /api/logs/rankings?limit=0 GET /api/logs/rankings?all=maybe ``` ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations The `limit` parameter is validated to be a positive integer before use; `all=true` is validated as a boolean. No user-supplied value is interpolated into SQL — the value is passed to GORM's `.Limit()` method only. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
occcat
pushed a commit
to occcat/bifrost
that referenced
this pull request
Sep 2, 2026
…p or remove ranking row limits (maximhq#5624) ## Summary Ranking queries (`GetModelRankings`, `GetUserRankings`, `GetDimensionRankings`) were previously hard-coded to return at most `defaultMaxRankingsLimit` (100) rows with no way for callers to override that cap. This made it impossible for the dashboard export to retrieve the full ranked list. This PR introduces a `RankingLimit` field on `SearchFilters` and exposes `all` / `limit` query parameters on the ranking HTTP endpoints so callers can request a custom cap or an uncapped result. ## Changes - Added `RankingLimit *int` to `SearchFilters` and an `EffectiveRankingLimit(defaultLimit int) int` helper that resolves `nil` → store default, `<= 0` → no cap, and `> 0` → explicit cap. - Extracted a shared `applyRankingLimit(q *gorm.DB, filters SearchFilters) *gorm.DB` helper in `rdb.go` that replaces the inline `.Limit(defaultMaxRankingsLimit)` calls in `GetModelRankings`, `GetUserRankings`, and `GetDimensionRankings`. - Applied the same `applyRankingLimit` pattern to the materialized-view-backed ranking paths in `matviews.go`, which previously had no limit at all. - Added `ParseRankingLimit` in the HTTP handler layer to parse `all=true` (uncapped, for exports) and `limit=<n>` (explicit positive cap) query parameters, writing a 400 on invalid input. - Wired `ParseRankingLimit` into `getModelRankings`, `getDimensionRankings`, and `getDashboard`. - Added `rdb_ranking_limit_test.go` with an in-memory SQLite store that seeds more rows than the default cap and verifies all four cases: default cap, explicit limit, limit above row count, and `all=true`. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [x] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go test ./framework/logstore/... -run TestGetDimensionRankingsRespectsRankingLimit go test ./framework/logstore/... -run TestGetModelRankingsRespectsRankingLimit go test ./... ``` To exercise the HTTP layer manually, call a ranking endpoint with the new parameters: ```sh # Return at most 10 rows GET /api/logs/rankings?limit=10 # Return every ranked entity (export use-case) GET /api/logs/rankings?all=true # Invalid inputs return HTTP 400 GET /api/logs/rankings?limit=0 GET /api/logs/rankings?all=maybe ``` ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations The `limit` parameter is validated to be a positive integer before use; `all=true` is validated as a boolean. No user-supplied value is interpolated into SQL — the value is passed to GORM's `.Limit()` method only. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
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.

Summary
Ranking queries (
GetModelRankings,GetUserRankings,GetDimensionRankings) were previously hard-coded to return at mostdefaultMaxRankingsLimit(100) rows with no way for callers to override that cap. This made it impossible for the dashboard export to retrieve the full ranked list. This PR introduces aRankingLimitfield onSearchFiltersand exposesall/limitquery parameters on the ranking HTTP endpoints so callers can request a custom cap or an uncapped result.Changes
RankingLimit *inttoSearchFiltersand anEffectiveRankingLimit(defaultLimit int) inthelper that resolvesnil→ store default,<= 0→ no cap, and> 0→ explicit cap.applyRankingLimit(q *gorm.DB, filters SearchFilters) *gorm.DBhelper inrdb.gothat replaces the inline.Limit(defaultMaxRankingsLimit)calls inGetModelRankings,GetUserRankings, andGetDimensionRankings.applyRankingLimitpattern to the materialized-view-backed ranking paths inmatviews.go, which previously had no limit at all.ParseRankingLimitin the HTTP handler layer to parseall=true(uncapped, for exports) andlimit=<n>(explicit positive cap) query parameters, writing a 400 on invalid input.ParseRankingLimitintogetModelRankings,getDimensionRankings, andgetDashboard.rdb_ranking_limit_test.gowith an in-memory SQLite store that seeds more rows than the default cap and verifies all four cases: default cap, explicit limit, limit above row count, andall=true.Type of change
Affected areas
How to test
To exercise the HTTP layer manually, call a ranking endpoint with the new parameters:
Breaking changes
Related issues
Security considerations
The
limitparameter is validated to be a positive integer before use;all=trueis validated as a boolean. No user-supplied value is interpolated into SQL — the value is passed to GORM's.Limit()method only.Checklist
docs/contributing/README.mdand followed the guidelines