mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(stats): add daily statistics aggregation job and model
- Create `DailyStat` model for immutable daily metrics including request counts, tokens, latency, and top models. - Implement `DailyStatsJob` to aggregate `log_records` from the previous day, running daily at 00:05 UTC. - Register database migrations and schedule the job in the server. - Add `last7d` and `last30d` period support to stats handler.
This commit is contained in:
@@ -264,6 +264,12 @@ func periodWindow(period string) (time.Time, time.Time) {
|
||||
case "month":
|
||||
start := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.UTC)
|
||||
return start, now
|
||||
case "last7d":
|
||||
start := now.AddDate(0, 0, -7)
|
||||
return start, now
|
||||
case "last30d":
|
||||
start := now.AddDate(0, 0, -30)
|
||||
return start, now
|
||||
default:
|
||||
return time.Time{}, time.Time{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user