feat: rearrange game benchmark wizard and improve overall
This commit is contained in:
@@ -79,6 +79,7 @@ interface Game {
|
||||
playabilityStatus?: "great" | "playable" | "needs_tweaks" | "unplayable" | "unknown" | null
|
||||
steamReviewScore?: number | null
|
||||
steamReviewSentiment?: string | null
|
||||
steamReviewCount?: number | null
|
||||
}
|
||||
|
||||
interface Counts {
|
||||
|
||||
+15
-3
@@ -254,16 +254,25 @@ export default async function GamePage({
|
||||
.orderBy(desc(performanceEntries.isPinned), desc(performanceEntries.upvotes)),
|
||||
])
|
||||
|
||||
// ── Sync logic: force or stale-while-revalidate ─────────────────
|
||||
// ── Sync logic: force or stale-while-revalidate ────────────────
|
||||
const shouldSync =
|
||||
game.source === "steam" &&
|
||||
game.steamAppId &&
|
||||
(forceSync || isSyncStale(game.lastSync))
|
||||
|
||||
if (shouldSync) {
|
||||
after(async () => {
|
||||
if (forceSync) {
|
||||
// Block render on forced sync so user sees fresh data immediately
|
||||
await syncSteamGame(game.steamAppId!)
|
||||
})
|
||||
// Re-fetch game after sync so serialized data is fresh
|
||||
const refreshed = await resolveGame(game.steamAppId!.toString())
|
||||
if (refreshed) game = refreshed
|
||||
} else {
|
||||
// Stale sync happens after response so page isn't delayed
|
||||
after(async () => {
|
||||
await syncSteamGame(game.steamAppId!)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize for client component (Dates → strings)
|
||||
@@ -293,6 +302,9 @@ export default async function GamePage({
|
||||
releaseDate: game.releaseDate,
|
||||
categories: game.categories,
|
||||
platforms: game.platforms,
|
||||
steamReviewScore: game.steamReviewScore,
|
||||
steamReviewSentiment: game.steamReviewSentiment,
|
||||
steamReviewCount: game.steamReviewCount,
|
||||
}
|
||||
|
||||
const serializedPresets = presetRows.map((p) => ({
|
||||
|
||||
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation"
|
||||
import { db } from "@/lib/db/index"
|
||||
import { games, gameVersions, performanceEntries, gamePlatformSupport } from "@/lib/db/schema"
|
||||
import { eq, sql } from "drizzle-orm"
|
||||
import { GameEntryWizard } from "@/components/wizard/game-entry-wizard"
|
||||
import { GameEntryWizard, type GameVersionInfo } from "@/components/wizard/game-entry-wizard"
|
||||
|
||||
// This page needs live data — skip static generation at build time
|
||||
export const dynamic = "force-dynamic"
|
||||
@@ -47,37 +47,34 @@ export default async function SubmitBenchmarkPage({
|
||||
notFound()
|
||||
}
|
||||
|
||||
// Get or create the latest game version
|
||||
let [version] = await db
|
||||
.select()
|
||||
// Fetch all game versions for version selection
|
||||
const allVersions = await db
|
||||
.select({
|
||||
id: gameVersions.id,
|
||||
versionString: gameVersions.versionString,
|
||||
buildId: gameVersions.buildId,
|
||||
isLatest: gameVersions.isLatest,
|
||||
})
|
||||
.from(gameVersions)
|
||||
.where(
|
||||
eq(gameVersions.gameId, game.id),
|
||||
)
|
||||
.where(eq(gameVersions.gameId, game.id))
|
||||
.orderBy(sql`${gameVersions.createdAt} DESC`)
|
||||
.limit(1)
|
||||
|
||||
// Create a default version if none exists
|
||||
if (!version) {
|
||||
[version] = await db
|
||||
if (allVersions.length === 0) {
|
||||
const [newVersion] = await db
|
||||
.insert(gameVersions)
|
||||
.values({
|
||||
gameId: game.id,
|
||||
isLatest: true,
|
||||
})
|
||||
.returning()
|
||||
}
|
||||
|
||||
// Fetch platform support for anti-cheat awareness
|
||||
const platformSupport = await db
|
||||
.select({
|
||||
hardwareSlug: gamePlatformSupport.hardwareSlug,
|
||||
antiCheatRelevant: gamePlatformSupport.antiCheatRelevant,
|
||||
antiCheatName: gamePlatformSupport.antiCheatName,
|
||||
antiCheatStatus: gamePlatformSupport.antiCheatStatus,
|
||||
allVersions.push({
|
||||
id: newVersion.id,
|
||||
versionString: newVersion.versionString,
|
||||
buildId: newVersion.buildId,
|
||||
isLatest: newVersion.isLatest,
|
||||
})
|
||||
.from(gamePlatformSupport)
|
||||
.where(eq(gamePlatformSupport.gameId, game.id))
|
||||
}
|
||||
|
||||
// If editing, fetch the existing performance entry
|
||||
let editEntry = null
|
||||
@@ -90,6 +87,26 @@ export default async function SubmitBenchmarkPage({
|
||||
editEntry = entry ?? null
|
||||
}
|
||||
|
||||
// Determine default version: when editing, use the entry's version;
|
||||
// otherwise, use the latest (first in DESC order)
|
||||
let defaultVersionId = allVersions[0].id
|
||||
if (editEntry?.versionId) {
|
||||
defaultVersionId = editEntry.versionId
|
||||
}
|
||||
|
||||
const gameVersionInfos: GameVersionInfo[] = allVersions
|
||||
|
||||
// Fetch platform support for anti-cheat awareness
|
||||
const platformSupport = await db
|
||||
.select({
|
||||
hardwareSlug: gamePlatformSupport.hardwareSlug,
|
||||
antiCheatRelevant: gamePlatformSupport.antiCheatRelevant,
|
||||
antiCheatName: gamePlatformSupport.antiCheatName,
|
||||
antiCheatStatus: gamePlatformSupport.antiCheatStatus,
|
||||
})
|
||||
.from(gamePlatformSupport)
|
||||
.where(eq(gamePlatformSupport.gameId, game.id))
|
||||
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-4 py-8 w-full">
|
||||
<div className="mb-8">
|
||||
@@ -104,7 +121,8 @@ export default async function SubmitBenchmarkPage({
|
||||
|
||||
<GameEntryWizard
|
||||
gameId={game.id}
|
||||
gameVersionId={version.id}
|
||||
gameVersions={gameVersionInfos}
|
||||
defaultVersionId={defaultVersionId}
|
||||
editEntry={editEntry}
|
||||
platformSupport={platformSupport}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user