Phase 3-B: Add Daily Snapshot Job + Usage History Endpoint #47
Labels
No Label
admin
agent-api
api
api-client
audit
backend
boards
cost-accounting
database
design
forgejo
frontend
issues
metrics
mutation
navigation
optional
phase:1
phase:2
phase:3
phase:4
phase:5
phase:6
polish
priority:high
priority:low
priority:medium
service
sync
usage-accuracy
validation
webhooks
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: null/Pipeline#47
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source plan:
/home/kaspa/.claude/plans/with-our-backend-created-precious-owl.mdFeature context: Feature 3: Daily Cost Snapshot (Historical Trending)
Scope
Phase 3-B — Backend, Batch 2: Snapshot Job + History Endpoint
Summary
Add an RQ background job that runs daily to write a snapshot, and a
GET /claude-code/usage/historyendpoint to read the history.Affected area
/claude-codeAffected files
backend/app/services/claude_code_reader.py— addsnapshot_today()functionbackend/app/tasks/claude_usage.py— new file, RQ tasktake_daily_snapshotscripts/rq-docker— register the daily snapshot cron (or use existing cron mechanism)backend/app/api/claude_code.py— addGET /claude-code/usage/historyroutebackend/app/schemas/claude_code.py— addUsageHistoryResponseschemaAffected routes or endpoints
GET /api/v1/claude-code/usage/history?range=7d|30d|90dExpected behavior
take_daily_snapshot(): reads currentlist_sessions(), aggregates totals by model, upserts aClaudeUsageSnapshotrow for today's dateGET /usage/history: returns an array of{date, total_cost_usd, total_tokens, session_count, per_model}sorted ascending by date, scoped to the requested rangeSteps to reproduce (acceptance criteria)
claude_usage_snapshotsfor todayGET /api/v1/claude-code/usage/history?range=7dreturns that row3-B: Backend, Batch 2: Snapshot Job + History Endpointto Phase 3-B: Add Daily Snapshot Job + Usage History Endpoint