refactor: replace communityPresets count with performanceEntries preset count
This commit is contained in:
@@ -4,7 +4,6 @@ import {
|
|||||||
games,
|
games,
|
||||||
gameVersions,
|
gameVersions,
|
||||||
performanceEntries,
|
performanceEntries,
|
||||||
communityPresets,
|
|
||||||
gameComments,
|
gameComments,
|
||||||
} from "@/lib/db/schema"
|
} from "@/lib/db/schema"
|
||||||
import { ilike, or, sql, eq, inArray, and } from "drizzle-orm"
|
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),
|
.groupBy(gameVersions.gameId),
|
||||||
db
|
db
|
||||||
.select({
|
.select({
|
||||||
gameId: communityPresets.gameId,
|
gameId: gameVersions.gameId,
|
||||||
count: sql<number>`count(*)::int`,
|
count: sql<number>`count(*)::int`,
|
||||||
})
|
})
|
||||||
.from(communityPresets)
|
.from(performanceEntries)
|
||||||
.where(inArray(communityPresets.gameId, localGameIds))
|
.innerJoin(
|
||||||
.groupBy(communityPresets.gameId),
|
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
|
db
|
||||||
.select({
|
.select({
|
||||||
gameId: gameComments.gameId,
|
gameId: gameComments.gameId,
|
||||||
|
|||||||
Reference in New Issue
Block a user