mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
refactor(stats): remove daily stats aggregation
Remove the DailyStatsJob, DailyStat model, and associated database migrations. This eliminates the pre-aggregation layer and updates the dashboard handler to remove dependencies on the daily_stats table.
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// TopModelStat represents a single model's statistics in the top models list
|
||||
type TopModelStat struct {
|
||||
Model string `json:"model"`
|
||||
Requests int64 `json:"requests"`
|
||||
Tokens int64 `json:"tokens"`
|
||||
}
|
||||
|
||||
// DailyStat stores immutable daily aggregated statistics.
|
||||
// Once generated by the cron job, a row is never modified.
|
||||
// Design principles:
|
||||
// - Immutable: once generated, never modified
|
||||
// - Store raw aggregates, compute derived values (error_rate, avg_latency) at read time
|
||||
// - One row per day, ~365 rows/year
|
||||
type DailyStat struct {
|
||||
Date string `gorm:"primaryKey;size:10" json:"date"` // "2006-01-02" (UTC)
|
||||
|
||||
// Request counts
|
||||
Requests int64 `json:"requests"`
|
||||
Success int64 `json:"success"`
|
||||
Failed int64 `json:"failed"`
|
||||
|
||||
// Token counts
|
||||
TokensIn int64 `json:"tokens_in"`
|
||||
TokensOut int64 `json:"tokens_out"`
|
||||
|
||||
// Latency (for avg calculation: avg = LatencySumMs / Requests)
|
||||
LatencySumMs int64 `json:"latency_sum_ms"`
|
||||
|
||||
// Top models (JSON array of TopModelStat)
|
||||
TopModels string `gorm:"type:text" json:"top_models"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// TableName specifies the table name for DailyStat
|
||||
func (DailyStat) TableName() string {
|
||||
return "daily_stats"
|
||||
}
|
||||
Reference in New Issue
Block a user