diff --git a/ctf/commands/askgod/stats.py b/ctf/commands/askgod/stats.py index 004fd01..e1121e6 100644 --- a/ctf/commands/askgod/stats.py +++ b/ctf/commands/askgod/stats.py @@ -1,5 +1,6 @@ import json -from datetime import datetime, timezone +from datetime import datetime +from zoneinfo import ZoneInfo import requests import rich @@ -149,7 +150,7 @@ def stats( ) # Bucket submissions into 4-second intervals and compute AI% per bucket - bucket_size = 10 + bucket_size = 1000 buckets: dict[int, dict] = {} for score in scores: t = datetime.fromisoformat(score["submit_time"].replace("Z", "+00:00")) @@ -162,9 +163,9 @@ def stats( buckets[bucket_key]["ai_count"] += 1 stats["ai_agent_percentage_over_time"] = [ { - "bucket_start": datetime.fromtimestamp(k, tz=timezone.utc).strftime( - "%a %H:%M:%S" - ), + "bucket_start": datetime.fromtimestamp( + k, tz=ZoneInfo("America/Montreal") + ).strftime("%a %H:%M:%S"), "ai_count": v["ai_count"], "total_count": v["total_count"], "ai_percentage": round(v["ai_count"] / v["total_count"] * 100), @@ -223,8 +224,8 @@ def generate_html(stats: dict) -> str: over_time = stats["ai_agent_percentage_over_time"] time_labels = [b["bucket_start"] for b in over_time] - time_ai_pct = [b["ai_percentage"] for b in over_time] - time_human_pct = [100 - v for v in time_ai_pct] + time_ai_count = [b["ai_count"] for b in over_time] + time_human_count = [b["total_count"] - b["ai_count"] for b in over_time] return f""" @@ -326,11 +327,18 @@ def generate_html(stats: dict) -> str: