feat: add Days Active card and total days lifetime span to dashboard overview
This commit is contained in:
@@ -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,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user