Home

boring / v2

publicBoring-Software-Inc/v2
Overview Code History Branches Pull requestsIssuesInsights Campfire Docs
main
HomeOverview Code PRsIssues

fix(db): per-rule sparkline series uses rolling hours-ago ordering

closed
#187 opened by detail-app[bot]detail/bug-fix/fix-db-per-rule-sparkline-series-uses-rolling-hour-08afd6→main
Conversation4
detail-app[bot]
Commits
0
Files changed…
opened this pull request
Author
· 2 weeks ago

Detail bug report: View on Detail

Closes #174

Bug

The per-rule sparkline series in getRulesStats (packages/db/src/services/insights.ts) bucketed by clock hour-of-day (extract(hour FROM s.started_at)) and wrote to stat.series[clockHour], while the top-level matchesSeries/actionedSeries in the same function were converted to rolling hours-ago ordering (series[23 - h]) in cb4771ee. The per-rule block was missed.

The Sparkline component contract is "oldest first, index 23 = now". Because the per-rule series flows unchanged to the UI (RuleStat.series → rule.trend → <Sparkline data={rule.trend}>), every rule card sparkline on /rules rendered a wrong timeline that disagreed with the header sparkline on the same page — a moderator reading "matches per hour, last 24 hours" saw activity attributed to the wrong hours (up to a full-day skew), and the screen-reader narration (trendWords) reported a direction computed from the wrong window edges.

Fix

Bucket the per-rule query by hours-ago (floor(extract(epoch FROM (now() - s.started_at)) / 3600)::int AS h) and write stat.series[23 - h] = n, mirroring the rollingSeries helper already used by matchesSeries and actionedSeries in the same function. This makes the per-rule series and the top-level series place the same event at the same index, so the header and card sparklines agree.

Testing

  • Added an integration test (insights.integration.test.ts) that seeds two rule-node fails at 5h and 10h ago and asserts both the top-level matches24h.series and the per-rule series place them at the same rolling indices (18 and 13). The test fails without the fix (Expected: 18, Received: 1 — the clock-hour bucket) and passes with it.
  • All 7 tests in the insights integration suite pass, and the full packages/db suite (350 tests across 38 files) passes — no regressions in repo scoping, actioned counts, or getHomeStats.
  • Typecheck (all 16 workspaces), Biome format/lint, and boundary checks all pass.
  • End-to-end verification: started the dev server via bun run dev:demo (PGlite, seeded demo), installed Playwright Chromium, and drove the /dev-owner/active-webapp/rules page in a headless browser. Extracted the SVG path data and <caption> text from all 6 rendered sparklines — each per-rule sparkline's events land at the same indices as the header sparkline, and the trendWords captions report directions consistent with the rolling ordering.

Automatic Fixes PRs can be configured here.

unkey-deploy[bot]commented· 2 weeks ago

The latest updates on your projects. Learn more about Unkey Deploy

NameStatusPreviewInspectUpdated (UTC)
tripwire / web (preview)ReadyVisit PreviewInspectNov 7, 2026 6:57am

Changes requested

tripwire-sh[bot] · 2 weeks ago

Blocked. See the comment.

tripwire-sh[bot]commented· 2 weeks ago

@detail-app[bot], Tripwire blocked this change request.

Rate limit: You opened 61 change requests in a short time. Wait before you open another.

View on Tripwire

How do I fix this?

A new commit will not fix this.

If you think it should merge anyway, say so in a comment. A maintainer will decide.

detail-app[bot]commented· 2 weeks ago

Re: github.com/Boring-Software-Inc/…/187

The only failing check is tripwire, which is blocked on a rate limit ("You opened 61 change requests in a short time"), not on anything in this PR. The PR's own CI check is green (gh pr checks 187 → check pass), and the PR is a focused 2-file bug fix — it switches the per-rule sparkline bucket from a clock-hour bucket to the same rolling hours-ago index (23 - h) the top-level matches24h.series uses, plus an integration test asserting the two series agree.

A new commit will not fix the rate-limit block (as the verdict notes), so I'm not pushing one. This should merge once the rate limit clears; flagging for a maintainer to decide.

Sign in to comment.

Merge readiness

Checking mergeability after the indexing worker computes the current branch state.

Autopilot

Debug

Reviews

Approved0
ReviewersNone yet

Configure an OpenRouter key in repository settings.