nice-bill commited on
Commit
5284b34
·
verified ·
1 Parent(s): f703f9f

deploy from github

Browse files
Files changed (2) hide show
  1. core/summarizer.py +8 -3
  2. web/app.py +33 -0
core/summarizer.py CHANGED
@@ -173,13 +173,18 @@ Keep the tone informative and analytical. Use markdown formatting for readabilit
173
 
174
  def summarize_and_save(self, run_id: int) -> Dict:
175
  """Generate summary and save to database."""
 
 
 
 
 
176
  summary_text = self.generate_summary(run_id)
177
 
178
- # Save to database
179
- summary_data = SummaryData(run_id=run_id, summary_text=summary_text)
180
  self.supabase.save_run_summary(summary_data)
181
 
182
  return {
183
- "run_id": run_id,
184
  "summary": summary_text
185
  }
 
173
 
174
  def summarize_and_save(self, run_id: int) -> Dict:
175
  """Generate summary and save to database."""
176
+ # Get run info to get the human-readable run_number
177
+ runs = self.supabase.get_all_runs()
178
+ run_info = next((r for r in runs if r["id"] == run_id), {})
179
+ run_number = run_info.get("run_number", run_id)
180
+
181
  summary_text = self.generate_summary(run_id)
182
 
183
+ # Save to database with run_number (not internal ID)
184
+ summary_data = SummaryData(run_id=run_number, summary_text=summary_text)
185
  self.supabase.save_run_summary(summary_data)
186
 
187
  return {
188
+ "run_id": run_number,
189
  "summary": summary_text
190
  }
web/app.py CHANGED
@@ -305,6 +305,39 @@ def reset_all():
305
  raise HTTPException(status_code=500, detail=str(e))
306
 
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  # ==================== Metrics Endpoints ====================
309
 
310
  @app.get("/api/metrics/{run_id}")
 
305
  raise HTTPException(status_code=500, detail=str(e))
306
 
307
 
308
+ @app.post("/api/admin/fix-summary-runids")
309
+ def fix_summary_runids():
310
+ """Fix summary run_id values to use run_number instead of internal ID."""
311
+ if not supabase:
312
+ raise HTTPException(status_code=503, detail="Supabase not configured")
313
+
314
+ try:
315
+ # Get all runs
316
+ runs = supabase.get_all_runs()
317
+ run_id_to_number = {r["id"]: r.get("run_number", r["id"]) for r in runs}
318
+
319
+ # Get all summaries
320
+ summaries = supabase.get_all_summaries()
321
+
322
+ fixed = 0
323
+ for summary in summaries:
324
+ old_run_id = summary.get("run_id")
325
+ if old_run_id in run_id_to_number:
326
+ correct_run_number = run_id_to_number[old_run_id]
327
+ if old_run_id != correct_run_number:
328
+ supabase.client.table("run_summaries").update({
329
+ "run_id": correct_run_number
330
+ }).eq("id", summary["id"]).execute()
331
+ fixed += 1
332
+
333
+ return {
334
+ "message": f"Fixed {fixed} summary run_ids",
335
+ "fixed": fixed
336
+ }
337
+ except Exception as e:
338
+ raise HTTPException(status_code=500, detail=str(e))
339
+
340
+
341
  # ==================== Metrics Endpoints ====================
342
 
343
  @app.get("/api/metrics/{run_id}")