nice-bill commited on
Commit
816b1c5
·
verified ·
1 Parent(s): 8c1d977

deploy from github

Browse files
Files changed (1) hide show
  1. web/app.py +32 -1
web/app.py CHANGED
@@ -338,6 +338,37 @@ def fix_summary_runids():
338
  raise HTTPException(status_code=500, detail=str(e))
339
 
340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  # ==================== Metrics Endpoints ====================
342
 
343
  @app.get("/api/metrics/{run_id}")
@@ -389,7 +420,7 @@ def get_action_distribution():
389
 
390
  action_counts = {}
391
  for run in completed_runs:
392
- actions = supabase.get_all_actions(run["id"])
393
  for action in actions:
394
  action_type = action.get("action_type", "unknown")
395
  # Filter out bonus actions for cleaner chart
 
338
  raise HTTPException(status_code=500, detail=str(e))
339
 
340
 
341
+ @app.post("/api/admin/fix-gini-values")
342
+ def fix_gini_values():
343
+ """Fix old Gini coefficient values that exceed 1.0."""
344
+ if not supabase:
345
+ raise HTTPException(status_code=503, detail="Supabase not configured")
346
+
347
+ try:
348
+ # Get all run metrics
349
+ runs = supabase.get_all_runs()
350
+ fixed = 0
351
+
352
+ for run in runs:
353
+ run_id = run["id"]
354
+ metrics = supabase.get_metrics(run_id)
355
+ if metrics:
356
+ gini = metrics.get("gini_coefficient", 0)
357
+ if gini > 1:
358
+ clamped_gini = max(0, min(1, gini))
359
+ supabase.client.table("run_metrics").update({
360
+ "gini_coefficient": clamped_gini
361
+ }).eq("id", metrics["id"]).execute()
362
+ fixed += 1
363
+
364
+ return {
365
+ "message": f"Fixed {fixed} Gini values",
366
+ "fixed": fixed
367
+ }
368
+ except Exception as e:
369
+ raise HTTPException(status_code=500, detail=str(e))
370
+
371
+
372
  # ==================== Metrics Endpoints ====================
373
 
374
  @app.get("/api/metrics/{run_id}")
 
420
 
421
  action_counts = {}
422
  for run in completed_runs:
423
+ actions = supabase.get_actions(run["id"])
424
  for action in actions:
425
  action_type = action.get("action_type", "unknown")
426
  # Filter out bonus actions for cleaner chart