fix: include benchmark games in device filter and exclude soft-deleted entries from search

Task 10: Device filter now combines games with platform support entries
AND games with performance entries for the selected hardware, instead of
only checking gamePlatformSupport. This ensures games that have benchmarks
but no explicit platform support entry still appear in filtered results.

Task 11: The benchmark count query (bCounts) in unified search now filters
out soft-deleted performance entries using isRemoved = false. The pCounts
and perfStats queries already had this filter; only bCounts was missing it.
This commit is contained in:
2026-04-29 01:43:37 +08:00
parent dfae540fd4
commit 8a063bfb6c
2 changed files with 24 additions and 3 deletions
+18 -2
View File
@@ -41,6 +41,7 @@ export const gamesListingRoutes = new Elysia({ prefix: "/games/listing" }).get(
}
if (device) {
// Get games with platform support
const supportedIds = await db
.select({ gameId: gamePlatformSupport.gameId })
.from(gamePlatformSupport)
@@ -50,8 +51,23 @@ export const gamesListingRoutes = new Elysia({ prefix: "/games/listing" }).get(
eq(gamePlatformSupport.isSupported, true),
),
)
if (supportedIds.length > 0) {
conditions.push(inArray(games.id, supportedIds.map((s) => s.gameId)))
// Also get games with performance entries for this hardware
const gamesWithBenchmarks = await db
.select({ gameId: gameVersions.gameId })
.from(performanceEntries)
.innerJoin(gameVersions, eq(performanceEntries.versionId, gameVersions.id))
.where(eq(performanceEntries.hardwareSlug, device))
.groupBy(gameVersions.gameId)
// Combine both sets
const deviceGameIds = new Set([
...supportedIds.map((s) => s.gameId),
...gamesWithBenchmarks.map((b) => b.gameId),
])
if (deviceGameIds.size > 0) {
conditions.push(inArray(games.id, Array.from(deviceGameIds)))
} else {
return { data: [], total: 0, limit, offset, genres: [], devices: [] }
}
+6 -1
View File
@@ -104,7 +104,12 @@ export const searchUnifiedRoutes = new Elysia({ prefix: "/search" }).get(
gameVersions,
eq(performanceEntries.versionId, gameVersions.id),
)
.where(inArray(gameVersions.gameId, localGameIds))
.where(
and(
inArray(gameVersions.gameId, localGameIds),
eq(performanceEntries.isRemoved, false),
),
)
.groupBy(gameVersions.gameId),
db
.select({