fix: resolve dashboard 401 and 500 errors
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Restricted AuthMiddleware to /v1 group to prevent dashboard session interference. Robustified analytics SQL queries with COALESCE to handle empty datasets.
This commit is contained in:
2026-03-19 12:35:14 -04:00
parent 26d8431998
commit 263c0f0dc9
2 changed files with 3 additions and 5 deletions

View File

@@ -304,7 +304,7 @@ func (s *Server) handleTimeSeries(c *gin.Context) {
query := fmt.Sprintf(`
SELECT
strftime('%%Y-%%m-%%d', timestamp) as bucket,
COALESCE(strftime('%%Y-%%m-%%d', timestamp), 'unknown') as bucket,
COUNT(*) as requests,
COALESCE(SUM(total_tokens), 0) as tokens,
COALESCE(SUM(cost), 0.0) as cost
@@ -444,7 +444,7 @@ func (s *Server) handleDetailedUsage(c *gin.Context) {
query := fmt.Sprintf(`
SELECT
strftime('%%Y-%%m-%%d', timestamp) as date,
COALESCE(strftime('%%Y-%%m-%%d', timestamp), 'unknown') as date,
COALESCE(client_id, 'unknown') as client,
COALESCE(provider, 'unknown') as provider,
COALESCE(model, 'unknown') as model,