mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
style(api): align struct field tags and fix string concatenation
- Fix JSON field alignment in error response and TrafficBucket struct - Add documentation comment and swagger annotations for Breakdown field - Remove unnecessary string concatenation spacing in SQL select
This commit is contained in:
@@ -620,7 +620,8 @@ type TrafficMetrics struct {
|
||||
type TrafficBucket struct {
|
||||
Time string `json:"time"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Breakdown map[string]TrafficMetrics `json:"breakdown"`
|
||||
// Breakdown contains per-model metrics, keyed by model name (e.g. "gpt-4", "claude-3-opus", "other")
|
||||
Breakdown map[string]TrafficMetrics `json:"breakdown" swaggertype:"object,object" example:"{\"gpt-4\":{\"count\":10,\"tokens_in\":1000,\"tokens_out\":500},\"claude-3-opus\":{\"count\":5,\"tokens_in\":800,\"tokens_out\":400},\"other\":{\"count\":3,\"tokens_in\":200,\"tokens_out\":100}}"`
|
||||
Total TrafficMetrics `json:"total"`
|
||||
}
|
||||
|
||||
@@ -734,7 +735,7 @@ func (h *Handler) GetTrafficChart(c *gin.Context) {
|
||||
}
|
||||
var rows []bucketModelStats
|
||||
|
||||
if err := q.Select(truncFunc+" as bucket, model_name, COUNT(*) as cnt, COALESCE(SUM(tokens_in),0) as tokens_in, COALESCE(SUM(tokens_out),0) as tokens_out").
|
||||
if err := q.Select(truncFunc + " as bucket, model_name, COUNT(*) as cnt, COALESCE(SUM(tokens_in),0) as tokens_in, COALESCE(SUM(tokens_out),0) as tokens_out").
|
||||
Group("bucket, model_name").
|
||||
Order("bucket ASC, cnt DESC").
|
||||
Scan(&rows).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user