fix: resolve dashboard 401 and 500 errors
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user