From 8a063bfb6cfca6a39285c14b8d00e97d48d65d9d Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Wed, 29 Apr 2026 01:43:37 +0800 Subject: [PATCH] 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. --- lib/api/games-listing.ts | 20 ++++++++++++++++++-- lib/api/search-unified.ts | 7 ++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/api/games-listing.ts b/lib/api/games-listing.ts index 63affea..69c81af 100644 --- a/lib/api/games-listing.ts +++ b/lib/api/games-listing.ts @@ -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: [] } } diff --git a/lib/api/search-unified.ts b/lib/api/search-unified.ts index 018243c..e5cf473 100644 --- a/lib/api/search-unified.ts +++ b/lib/api/search-unified.ts @@ -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({