321125b2
stats: add /api/v1/stats aggregate endpoint
Implements Phase 2 of lethe-web-ui-aggregates: a single-round-trip /api/v1/stats endpoint that bundles per-tool rollup, daily time-series, 84-cell activity heatmap, top-cwd ranking, hour-of-day distribution, and host split. All six aggregations run fresh per request; no server cache. - internal/domain/stats/buckets.go: pure helpers DailyWindow, FillDaily, HeatmapWindow, HourWindow — fully deterministic, tested independently. - internal/domain/stats/repository.go: Filter/Stats types and Repository.Stats — six SQL queries joined via sessions+turns, owner scope via OwnerScope (AllOwners / SpecificOwner / default), sparkline capped at 60 buckets. - internal/domain/stats/handler.go: Handler.List — ?range=7d|30d|90d|all (default 30d); ?range=<other> → 400 INVALID; ?owner= non-admin → 403. - internal/server/server.go: register *stats.Handler alongside project/sessions. - cmd/lethe/main.go: add statsRepo/statsHnd to var block and steward graph. - cmd/lethe/main_e2e_test.go: add stats.Repository/Handler to e2e graph.
Eugene Blikh <bigbes@gmail.com> — 2026-04-26 05:22:57 UTC
Commit 321125b29b8dcde4046cf019b588f2bfe4e96d2a —
view raw patch
Parent(s):
2285c578
| File | Status | + | − |
|---|---|---|---|
cmd/lethe/main.go
|
M | +6 | -1 |
cmd/lethe/main_e2e_test.go
|
M | +3 | |
internal/domain/stats/buckets.go
|
A | +67 | |
internal/domain/stats/buckets_test.go
|
A | +237 | |
internal/domain/stats/handler.go
|
A | +112 | |
internal/domain/stats/handler_test.go
|
A | +197 | |
internal/domain/stats/repository.go
|
A | +386 | |
internal/domain/stats/repository_test.go
|
A | +346 | |
internal/server/server.go
|
M | +3 |