(challenge_id: str)
| 390 | |
| 391 | @app.get("/api/challenges/{challenge_id}/leaderboard") |
| 392 | def leaderboard(challenge_id: str) -> dict: |
| 393 | with connect() as conn: |
| 394 | rows = conn.execute( |
| 395 | """ |
| 396 | SELECT p.id, p.nickname, COUNT(u.cell_id) AS unlocked_cells, |
| 397 | MAX(u.created_at) AS last_unlocked_at |
| 398 | FROM user_unlocked_cells u |
| 399 | JOIN participants p ON p.id = u.participant_id |
| 400 | WHERE u.challenge_id = ? |
| 401 | GROUP BY p.id, p.nickname |
| 402 | ORDER BY unlocked_cells DESC, last_unlocked_at ASC |
| 403 | LIMIT 100 |
| 404 | """, |
| 405 | (challenge_id,), |
| 406 | ).fetchall() |
| 407 | return {"leaderboard": [row_to_dict(row) for row in rows]} |
| 408 | |
| 409 | |
| 410 | @app.post("/api/challenges/{challenge_id}/unlock") |
nothing calls this directly
no test coverage detected