refactor: replace communityPresets count with performanceEntries preset count

This commit is contained in:
2026-04-27 14:11:27 +08:00
parent aa098ebaf8
commit 2ff54e58b3
+14 -5
View File
@@ -4,7 +4,6 @@ import {
games,
gameVersions,
performanceEntries,
communityPresets,
gameComments,
} from "@/lib/db/schema"
import { ilike, or, sql, eq, inArray, and } from "drizzle-orm"
@@ -109,12 +108,22 @@ export const searchUnifiedRoutes = new Elysia({ prefix: "/search" }).get(
.groupBy(gameVersions.gameId),
db
.select({
gameId: communityPresets.gameId,
gameId: gameVersions.gameId,
count: sql<number>`count(*)::int`,
})
.from(communityPresets)
.where(inArray(communityPresets.gameId, localGameIds))
.groupBy(communityPresets.gameId),
.from(performanceEntries)
.innerJoin(
gameVersions,
eq(performanceEntries.versionId, gameVersions.id),
)
.where(
and(
inArray(gameVersions.gameId, localGameIds),
eq(performanceEntries.isRemoved, false),
sql`${performanceEntries.settingsJson} IS NOT NULL`,
),
)
.groupBy(gameVersions.gameId),
db
.select({
gameId: gameComments.gameId,