fix: exclude null FPS entries from avgFps calculation in device stats API

This commit is contained in:
2026-04-27 20:36:29 +08:00
parent ecd83b1d70
commit 599cb024c9
+8 -3
View File
@@ -158,9 +158,14 @@ export const hardwareStatsRoutes = new Elysia({ prefix: "/hardware" })
} }
const totalBenchmarks = entries.length const totalBenchmarks = entries.length
const avgFps = Math.round( // Filter out null FPS entries before computing average (SQL avg() ignores nulls)
(entries.reduce((s, e) => s + (e.fpsAvg ?? 0), 0) / totalBenchmarks) * 10 const fpsEntries = entries.filter((e) => e.fpsAvg !== null)
) / 10 const avgFps =
fpsEntries.length > 0
? Math.round(
(fpsEntries.reduce((s, e) => s + e.fpsAvg!, 0) / fpsEntries.length) * 10
) / 10
: null
const verifiedCount = entries.filter((e) => e.verifiedAt !== null).length const verifiedCount = entries.filter((e) => e.verifiedAt !== null).length
// Unique game count // Unique game count