feat: add live activity aggregation with today-hourly and last-hour bucketing
Add data layer support for real-time usage visualization: - MinuteStats type: holds token counts for 5-minute buckets, enabling granular recent-activity views (12 buckets covering the last hour). - AggregateTodayHourly(): computes 24 hourly token buckets for the current local day by filtering sessions to today's date boundary and slotting each into the correct hour index. Tracks prompts, sessions, and total tokens per hour. - AggregateLastHour(): computes 12 five-minute token buckets for the last 60 minutes using reverse-offset bucketing (bucket 11 = most recent 5 minutes, bucket 0 = 55-60 minutes ago). Bounds-clamped to prevent off-by-one at the edges. Both functions filter on StartTime locality and skip zero-time sessions, consistent with existing aggregation patterns in the pipeline package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,3 +92,9 @@ type PeriodComparison struct {
|
||||
Current SummaryStats
|
||||
Previous SummaryStats
|
||||
}
|
||||
|
||||
// MinuteStats holds token counts for a 5-minute bucket.
|
||||
type MinuteStats struct {
|
||||
Minute int // 0-11 (bucket index within the hour)
|
||||
Tokens int64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user