diff --git a/lib/api/dashboard-public.ts b/lib/api/dashboard-public.ts index 823d686..fbd8da7 100644 --- a/lib/api/dashboard-public.ts +++ b/lib/api/dashboard-public.ts @@ -99,7 +99,8 @@ export const dashboardPublicRoutes = new Elysia({ prefix: "/dashboard", detail: g.capsule_image, g.header_image, g.playability_status, - COUNT(pe.id) AS benchmark_count + COUNT(pe.id) AS benchmark_count, + AVG(pe.fps_avg) AS avg_fps FROM games g JOIN game_versions gv ON gv.game_id = g.id JOIN performance_entries pe ON pe.version_id = gv.id @@ -113,6 +114,33 @@ export const dashboardPublicRoutes = new Elysia({ prefix: "/dashboard", detail: }, ) + // ── Recently Added Benchmarks ────────────────────────────────────── + .get( + "/recent-benchmarks", + async () => { + const results = await db.execute(sql` + SELECT + g.id, + g.title, + g.capsule_image, + g.header_image, + g.playability_status, + COUNT(pe.id) AS benchmark_count, + AVG(pe.fps_avg) AS avg_fps, + MAX(pe.created_at) AS latest_benchmark_at + FROM games g + JOIN game_versions gv ON gv.game_id = g.id + JOIN performance_entries pe ON pe.version_id = gv.id + WHERE pe.is_removed = false + GROUP BY g.id, g.title, g.capsule_image, g.header_image, g.playability_status + ORDER BY MAX(pe.created_at) DESC + LIMIT 10 + `) + + return results.rows + }, + ) + // ── Most Reported Games ──────────────────────────────────────────── .get( "/most-reported",