Skip to content

perf(api): simplify hourly balance history query#910

Open
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-balance-history-hourly-query
Open

perf(api): simplify hourly balance history query#910
raymondjacobson wants to merge 1 commit into
mainfrom
codex/db-audit-balance-history-hourly-query

Conversation

@raymondjacobson
Copy link
Copy Markdown
Member

Summary

  • uses a direct grouped query for hourly balance history responses
  • keeps daily balance history on the existing end-of-day semantics, but removes the runtime granularity CASE
  • removes the unused @granularity bind from this endpoint query

Production evidence

  • the database audit found /v1/users/:id/balance/history paying for the daily bucketing/DISTINCT layer even when the default granularity=hourly path only needs hourly totals
  • hourly callers now use the covered user_id/timestamp predicate, GROUP BY timestamp, and ORDER BY timestamp ASC directly
  • daily callers still sum mints per hour first and then pick the latest hour per day

Verification

  • go test ./api -run 'TestUserBalanceHistory' -count=1 -timeout=2m

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.

1 participant