feat(api): add /recent-benchmarks endpoint and avg_fps to most-tested

This commit is contained in:
2026-05-15 01:35:06 +08:00
parent 45d4570665
commit 1e546ca007
+29 -1
View File
@@ -99,7 +99,8 @@ export const dashboardPublicRoutes = new Elysia({ prefix: "/dashboard", detail:
g.capsule_image, g.capsule_image,
g.header_image, g.header_image,
g.playability_status, 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 FROM games g
JOIN game_versions gv ON gv.game_id = g.id JOIN game_versions gv ON gv.game_id = g.id
JOIN performance_entries pe ON pe.version_id = gv.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 ──────────────────────────────────────────── // ── Most Reported Games ────────────────────────────────────────────
.get( .get(
"/most-reported", "/most-reported",