feat: add system requirements, store stats, and pricing to game schema and steam sync

This commit is contained in:
2026-04-28 23:13:08 +08:00
parent 7e2ab978e1
commit 799bfbbf31
6 changed files with 1786 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
ALTER TABLE "games" ADD COLUMN "system_requirements" jsonb;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "metacritic_score" integer;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "metacritic_url" text;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "recommendations_total" integer;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "price_current" integer;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "price_initial" integer;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "price_currency" text;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "is_free" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "release_date" text;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "categories" jsonb;--> statement-breakpoint
ALTER TABLE "games" ADD COLUMN "platforms" jsonb;
File diff suppressed because it is too large Load Diff
+7
View File
@@ -78,6 +78,13 @@
"when": 1777386687207, "when": 1777386687207,
"tag": "0010_soft_wilson_fisk", "tag": "0010_soft_wilson_fisk",
"breakpoints": true "breakpoints": true
},
{
"idx": 11,
"version": "7",
"when": 1777389114548,
"tag": "0011_talented_bloodstorm",
"breakpoints": true
} }
] ]
} }
+21
View File
@@ -12,6 +12,14 @@ interface SteamAppDetails {
header_image?: string header_image?: string
genres?: { id: string; description: string }[] genres?: { id: string; description: string }[]
website?: string website?: string
pc_requirements?: { minimum?: string; recommended?: string }
metacritic?: { score: number; url: string }
recommendations?: { total: number }
price_overview?: { currency: string; initial: number; final: number }
is_free?: boolean
release_date?: { coming_soon: boolean; date: string }
categories?: { id: string; description: string }[]
platforms?: { windows: boolean; mac: boolean; linux: boolean }
} }
export const gameStubRoutes = new Elysia({ prefix: "/games" }).post( export const gameStubRoutes = new Elysia({ prefix: "/games" }).post(
@@ -81,6 +89,19 @@ export const gameStubRoutes = new Elysia({ prefix: "/games" }).post(
headerImage, headerImage,
capsuleImage, capsuleImage,
storeUrl: `https://store.steampowered.com/app/${body.steamAppId}`, storeUrl: `https://store.steampowered.com/app/${body.steamAppId}`,
systemRequirements: details?.pc_requirements
? { minimum: details.pc_requirements.minimum || null, recommended: details.pc_requirements.recommended || null }
: null,
metacriticScore: details?.metacritic?.score ?? null,
metacriticUrl: details?.metacritic?.url ?? null,
recommendationsTotal: details?.recommendations?.total ?? null,
priceCurrent: details?.price_overview?.final ?? null,
priceInitial: details?.price_overview?.initial ?? null,
priceCurrency: details?.price_overview?.currency ?? null,
isFree: details?.is_free ?? false,
releaseDate: details?.release_date?.date ?? null,
categories: details?.categories?.map((c) => c.description) ?? null,
platforms: details?.platforms ?? null,
lastSync: new Date(), lastSync: new Date(),
syncStatus: "synced", syncStatus: "synced",
}) })
+19
View File
@@ -1,4 +1,5 @@
import { import {
boolean,
integer, integer,
jsonb, jsonb,
pgEnum, pgEnum,
@@ -41,6 +42,24 @@ export const games = pgTable(
) )
.default("unknown") .default("unknown")
.notNull(), .notNull(),
systemRequirements: jsonb("system_requirements").$type<{
minimum: string | null
recommended: string | null
}>(),
metacriticScore: integer("metacritic_score"),
metacriticUrl: text("metacritic_url"),
recommendationsTotal: integer("recommendations_total"),
priceCurrent: integer("price_current"),
priceInitial: integer("price_initial"),
priceCurrency: text("price_currency"),
isFree: boolean("is_free").default(false).notNull(),
releaseDate: text("release_date"),
categories: jsonb("categories").$type<string[]>(),
platforms: jsonb("platforms").$type<{
windows: boolean
mac: boolean
linux: boolean
}>(),
lastSync: timestamp("last_sync"), lastSync: timestamp("last_sync"),
syncStatus: text("sync_status").default("pending"), syncStatus: text("sync_status").default("pending"),
createdAt: timestamp("created_at").defaultNow().notNull(), createdAt: timestamp("created_at").defaultNow().notNull(),
+21
View File
@@ -11,6 +11,14 @@ interface SteamAppDetails {
genres?: { id: string; description: string }[] genres?: { id: string; description: string }[]
website?: string website?: string
short_description?: string short_description?: string
pc_requirements?: { minimum?: string; recommended?: string }
metacritic?: { score: number; url: string }
recommendations?: { total: number }
price_overview?: { currency: string; initial: number; final: number }
is_free?: boolean
release_date?: { coming_soon: boolean; date: string }
categories?: { id: string; description: string }[]
platforms?: { windows: boolean; mac: boolean; linux: boolean }
} }
const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000 const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000
@@ -60,6 +68,19 @@ export async function syncSteamGame(steamAppId: number): Promise<void> {
headerImage: d.header_image || null, headerImage: d.header_image || null,
capsuleImage: `https://cdn.akamai.steamstatic.com/steam/apps/${steamAppId}/library_600x900.jpg`, capsuleImage: `https://cdn.akamai.steamstatic.com/steam/apps/${steamAppId}/library_600x900.jpg`,
storeUrl: `https://store.steampowered.com/app/${steamAppId}`, storeUrl: `https://store.steampowered.com/app/${steamAppId}`,
systemRequirements: d.pc_requirements
? { minimum: d.pc_requirements.minimum || null, recommended: d.pc_requirements.recommended || null }
: null,
metacriticScore: d.metacritic?.score ?? null,
metacriticUrl: d.metacritic?.url ?? null,
recommendationsTotal: d.recommendations?.total ?? null,
priceCurrent: d.price_overview?.final ?? null,
priceInitial: d.price_overview?.initial ?? null,
priceCurrency: d.price_overview?.currency ?? null,
isFree: d.is_free ?? false,
releaseDate: d.release_date?.date ?? null,
categories: d.categories?.map((c) => c.description) ?? null,
platforms: d.platforms ?? null,
lastSync: new Date(), lastSync: new Date(),
syncStatus: "synced", syncStatus: "synced",
updatedAt: new Date(), updatedAt: new Date(),