feat: add Days Active card and total days lifetime span to dashboard overview
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

This commit is contained in:
2026-07-21 18:11:18 +00:00
parent d23da551ab
commit 59c38e8f8f
2 changed files with 31 additions and 1 deletions
+17
View File
@@ -123,6 +123,21 @@ func (s *Server) handleUsageSummary(c *gin.Context) {
miscStats.AvgResponseTime = 0.0
}
// Lifetime days & start date
var lifetimeStats struct {
TotalDays int `db:"total_days"`
FirstDate string `db:"first_date"`
}
_ = s.database.Get(&lifetimeStats, `
SELECT
CAST(ROUND(COALESCE(julianday(substr(MAX(timestamp), 1, 19)) - julianday(substr(MIN(timestamp), 1, 19)), 1.0)) AS INTEGER) as total_days,
COALESCE(substr(MIN(timestamp), 1, 10), '') as first_date
FROM llm_requests
`)
if lifetimeStats.TotalDays < 1 {
lifetimeStats.TotalDays = 1
}
c.JSON(http.StatusOK, SuccessResponse(gin.H{
"total_requests": totalStats.TotalRequests,
"total_tokens": totalStats.TotalTokens,
@@ -134,6 +149,8 @@ func (s *Server) handleUsageSummary(c *gin.Context) {
"today_cost": todayStats.TodayCost,
"error_rate": miscStats.ErrorRate,
"avg_response_time": miscStats.AvgResponseTime,
"total_days": lifetimeStats.TotalDays,
"first_date": lifetimeStats.FirstDate,
}))
}