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:
@@ -41,6 +41,7 @@ export const gamesListingRoutes = new Elysia({ prefix: "/games/listing" }).get(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (device) {
|
if (device) {
|
||||||
|
// Get games with platform support
|
||||||
const supportedIds = await db
|
const supportedIds = await db
|
||||||
.select({ gameId: gamePlatformSupport.gameId })
|
.select({ gameId: gamePlatformSupport.gameId })
|
||||||
.from(gamePlatformSupport)
|
.from(gamePlatformSupport)
|
||||||
@@ -50,8 +51,23 @@ export const gamesListingRoutes = new Elysia({ prefix: "/games/listing" }).get(
|
|||||||
eq(gamePlatformSupport.isSupported, true),
|
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 {
|
} else {
|
||||||
return { data: [], total: 0, limit, offset, genres: [], devices: [] }
|
return { data: [], total: 0, limit, offset, genres: [], devices: [] }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,12 @@ export const searchUnifiedRoutes = new Elysia({ prefix: "/search" }).get(
|
|||||||
gameVersions,
|
gameVersions,
|
||||||
eq(performanceEntries.versionId, gameVersions.id),
|
eq(performanceEntries.versionId, gameVersions.id),
|
||||||
)
|
)
|
||||||
.where(inArray(gameVersions.gameId, localGameIds))
|
.where(
|
||||||
|
and(
|
||||||
|
inArray(gameVersions.gameId, localGameIds),
|
||||||
|
eq(performanceEntries.isRemoved, false),
|
||||||
|
),
|
||||||
|
)
|
||||||
.groupBy(gameVersions.gameId),
|
.groupBy(gameVersions.gameId),
|
||||||
db
|
db
|
||||||
.select({
|
.select({
|
||||||
|
|||||||
Reference in New Issue
Block a user