fix(dashboard): window the slop/duplicate trend read by time, not a 2-per-week row cap - #9803
Conversation
…-per-week row cap `SLOP_DUPLICATE_TREND_SNAPSHOT_LIMIT` was `WEEKS * 2 = 16` on the false premise that queue-health snapshots are written twice a week. They are written up to once per repo per generate-signal-snapshots run (several per day), so the row cap kept only the most recent ~4 days and the 8-week trend card was almost entirely empty. Add an optional `sinceIso` to `listRecentSignalSnapshotsForTargets`, applied as `AND generated_at >= ?` INSIDE the windowed subquery so row_number() ranks over the time-bounded set (not the whole table); the route passes an 8-week bound derived from the request's generatedAt. `maxPerTarget` stays a hard backstop, re-budgeted to WEEKS * 28 (clamped to the query's 100 ceiling). Omitting sinceIso is byte-identical to today. Closes JSONbored#9699
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 10:33:18 UTC
Review summary Nits — 1 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Decision record
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9803 +/- ##
===========================================
- Coverage 90.33% 78.06% -12.27%
===========================================
Files 918 286 -632
Lines 113943 64256 -49687
Branches 26979 9966 -17013
===========================================
- Hits 102933 50164 -52769
- Misses 9681 13669 +3988
+ Partials 1329 423 -906
Flags with carried forward coverage won't be shown. Click here to find out more.
|
What & why
SLOP_DUPLICATE_TREND_SNAPSHOT_LIMITwasSLOP_DUPLICATE_TREND_WEEKS * 2 = 16, documented as "two per week of history". That premise is false:queue-healthsnapshots are written up to once per repo pergenerate-signal-snapshotsrun (several per day). So the 16-row cap kept only the most recent ~4 days, and the maintainer dashboard's 8-week slop/duplicate trend card was almost entirely empty —row_number()ranked the cap within the last few days and never surfaced the older weeks.The fix
sinceIso?: stringtolistRecentSignalSnapshotsForTargets, applied asAND generated_at >= ?inside the windowed subquery, so the ranking is computed over the time-bounded set rather than the whole table. Bound as the fourth-then-fifth SQL param so it precedes the outersnapshot_rank <= ?cap.GET /v1/app/maintainer-dashboardpasses an 8-weeksinceIsoderived from the request'sgeneratedAt.maxPerTargetstays a hard backstop, re-budgeted toWEEKS * 28(clamped to the query's existing 100 ceiling) so the time bound — not the row cap — is the primary constraint.sinceIsois byte-identical to today.Tests
test/unit/data-spine.test.ts:sinceIsodrops out-of-window rows even with a generous cap, and ranks only the in-window set (fails onmain).sinceIso(undefined) returns the same rows as before.test/unit/maintainer-slop-duplicate-trend.test.ts:min(WEEKS * 28, 100), notWEEKS * 2(fails onmain).The route line is exercised by the existing
/v1/app/maintainer-dashboardintegration test.Validation
npm run typecheckgreen;npm run ui:openapi:checkclean (no schema change —sinceIsois an internal computed arg); the two touched unit suites green.sinceIsopresent/omitted arms).git diff --check <base> HEADclean; no migration change.Closes #9699