Spaces:
Runtime error
Runtime error
Update scripts/codeforces_api.py
Browse files- scripts/codeforces_api.py +8 -13
scripts/codeforces_api.py
CHANGED
|
@@ -3,19 +3,14 @@ import json
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
def run_cf_sync():
|
| 6 |
-
# Fetch
|
| 7 |
c_resp = requests.get("https://codeforces.com/api/contest.list?gym=false")
|
| 8 |
-
contests = [c for c in c_resp.json()['result'] if c
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
output_path = "cf_data.json"
|
| 18 |
-
with open(output_path, "w") as f:
|
| 19 |
-
json.dump(data, f)
|
| 20 |
-
|
| 21 |
-
return output_path # Crucial for Gradio to find the file
|
|
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
def run_cf_sync():
|
| 6 |
+
# 1. Fetch data from Codeforces
|
| 7 |
c_resp = requests.get("https://codeforces.com/api/contest.list?gym=false")
|
| 8 |
+
contests = [c for c in c_resp.json()['result'] if c.get('phase') == "FINISHED"]
|
| 9 |
|
| 10 |
+
# 2. Logic to group/process (Simplified for example)
|
| 11 |
+
output_filename = "cf_contests.json"
|
| 12 |
+
with open(output_filename, "w") as f:
|
| 13 |
+
json.dump(contests[:50], f) # Limit for speed
|
| 14 |
|
| 15 |
+
# 3. Return the absolute path so Gradio can find the file
|
| 16 |
+
return os.path.abspath(output_filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|