From 59c38e8f8fc897f1cdde493a16fcc27ea10b0dd4 Mon Sep 17 00:00:00 2001 From: hobokenchicken Date: Tue, 21 Jul 2026 18:11:18 +0000 Subject: [PATCH] feat: add Days Active card and total days lifetime span to dashboard overview --- internal/server/analytics.go | 17 +++++++++++++++++ static/js/pages/overview.js | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/internal/server/analytics.go b/internal/server/analytics.go index 5f0d751b..8de8960c 100644 --- a/internal/server/analytics.go +++ b/internal/server/analytics.go @@ -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, })) } diff --git a/static/js/pages/overview.js b/static/js/pages/overview.js index 7baa51be..d2599697 100644 --- a/static/js/pages/overview.js +++ b/static/js/pages/overview.js @@ -59,7 +59,20 @@ class OverviewPage {
${window.api.formatNumber(this.stats.total_tokens)}
Total Tokens
- Lifetime usage + Lifetime usage (${(this.stats.total_days || 1).toLocaleString()} days) +
+ + + +
+
+ +
+
+
${(this.stats.total_days || 1).toLocaleString()} Days
+
Days Active
+
+ Since ${this.stats.first_date || 'launch'}