()
| 531 | |
| 532 | @app.get("/api/admin/summary") |
| 533 | def admin_summary() -> dict: |
| 534 | with connect() as conn: |
| 535 | challenge_count = conn.execute( |
| 536 | "SELECT COUNT(*) AS c FROM challenges" |
| 537 | ).fetchone()["c"] |
| 538 | participant_count = conn.execute( |
| 539 | "SELECT COUNT(*) AS c FROM participants" |
| 540 | ).fetchone()["c"] |
| 541 | unlocked_count = conn.execute( |
| 542 | "SELECT COUNT(*) AS c FROM user_unlocked_cells" |
| 543 | ).fetchone()["c"] |
| 544 | event_count = conn.execute( |
| 545 | "SELECT COUNT(*) AS c FROM anti_cheat_events" |
| 546 | ).fetchone()["c"] |
| 547 | challenges = [ |
| 548 | public_challenge(conn, row) |
| 549 | for row in conn.execute( |
| 550 | "SELECT * FROM challenges ORDER BY created_at DESC LIMIT 20" |
| 551 | ).fetchall() |
| 552 | ] |
| 553 | events = [ |
| 554 | row_to_dict(row) |
| 555 | for row in conn.execute( |
| 556 | """ |
| 557 | SELECT reason, COUNT(*) AS count |
| 558 | FROM anti_cheat_events |
| 559 | GROUP BY reason |
| 560 | ORDER BY count DESC |
| 561 | """ |
| 562 | ).fetchall() |
| 563 | ] |
| 564 | unlock_sources = [ |
| 565 | row_to_dict(row) |
| 566 | for row in conn.execute( |
| 567 | """ |
| 568 | SELECT source, COUNT(*) AS count |
| 569 | FROM user_unlocked_cells |
| 570 | GROUP BY source |
| 571 | ORDER BY count DESC |
| 572 | """ |
| 573 | ).fetchall() |
| 574 | ] |
| 575 | recent_unlocks = [ |
| 576 | row_to_dict(row) |
| 577 | for row in conn.execute( |
| 578 | """ |
| 579 | SELECT u.challenge_id, c.name AS challenge_name, p.nickname, u.source, |
| 580 | u.accuracy_m, u.speed_mps, u.created_at |
| 581 | FROM user_unlocked_cells u |
| 582 | JOIN challenges c ON c.id = u.challenge_id |
| 583 | JOIN participants p ON p.id = u.participant_id |
| 584 | ORDER BY u.created_at DESC |
| 585 | LIMIT 20 |
| 586 | """ |
| 587 | ).fetchall() |
| 588 | ] |
| 589 | return { |
| 590 | "totals": { |
nothing calls this directly
no test coverage detected