Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ this project adheres to [Semantic Versioning](https://semver.org/).
- Schedule ingestion (`SchedulePoller`): real leagues and matches are upserted
into the DB around the clock — the API serves real data even when no game
is live.
- Built-in test dashboard at `/dashboard` (static, zero build): overview stats,
leagues, paginated matches, game inspector (event timeline + gold-diff
sparkline), live WebSocket console and request log.

- Pydantic response models and a generic `Page` pagination envelope.
- `limit` / `offset` pagination on `/matches`, `/games/{id}/events`, `/games/{id}/frames`.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ make dev # venv + install + pre-commit (or: pip install -e ".[d
cp .env.example .env

make run # API → http://localhost:8000/docs
make worker # worker → ingests when a match is live
make worker # worker → schedule (24/7) + live games ingestion
```

Then open the **test dashboard** at <http://localhost:8000/dashboard> — overview, leagues, matches, game inspector (events timeline + gold sparkline) and a live WebSocket console.

## Endpoints

| Method | Route | Returns |
Expand All @@ -59,6 +61,7 @@ make worker # worker → ingests when a match is live
| GET | `/games/{id}/events` | derived events (KILL/TOWER/DRAGON/BARON/INHIB) |
| GET | `/games/{id}/frames` | raw frames |
| WS | `/live/{id}` | live push: `subscribed` ack, then `event` / `score` messages |
| GET | `/dashboard` | built-in test dashboard (leagues, matches, game inspector, live WS console) |

## Prod (Docker, Postgres)

Expand Down
13 changes: 13 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import asyncio
import contextlib
from contextlib import asynccontextmanager
from pathlib import Path

import httpx
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from fastapi.staticfiles import StaticFiles

from app.api.routes import router
from app.bus import get_bus
Expand Down Expand Up @@ -74,3 +77,13 @@ async def _run_ingestion() -> None:
@app.get("/health", tags=["catalog"], summary="Health check")
async def health():
return {"status": "ok"}


# Test dashboard (static, no build step) — served at /dashboard if web/ exists.
_WEB_DIR = Path(__file__).resolve().parent.parent / "web"
if _WEB_DIR.is_dir():
app.mount("/dashboard", StaticFiles(directory=_WEB_DIR, html=True), name="dashboard")

@app.get("/", include_in_schema=False)
async def root() -> RedirectResponse:
return RedirectResponse(url="/dashboard/")
19 changes: 19 additions & 0 deletions tests/test_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""The static test dashboard is served at /dashboard."""

from fastapi.testclient import TestClient

from app.main import app


def test_dashboard_is_served():
with TestClient(app) as client:
r = client.get("/dashboard/")
assert r.status_code == 200
assert "control room" in r.text


def test_root_redirects_to_dashboard():
with TestClient(app) as client:
r = client.get("/", follow_redirects=False)
assert r.status_code == 307
assert r.headers["location"] == "/dashboard/"
Loading