From 7b7447a4caf94d03fd64ad98e7924556d06181c4 Mon Sep 17 00:00:00 2001 From: jy95 Date: Mon, 12 Aug 2024 01:58:39 +0200 Subject: [PATCH] chore: put information into database (WIP) --- GamesPassionFR.db | Bin 106496 -> 106496 bytes GamesPassionFR.sqbpro | 2 +- generateJsonFile.mjs | 23 ++++++++++++++++++++++- src/app/api/planning/route.ts | 14 ++------------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/GamesPassionFR.db b/GamesPassionFR.db index 2c2aa12b805bdbfbf8afb78ca8a86926724e230d..42994c739a4ccb8c3835a0e32c8752d732c2902a 100644 GIT binary patch delta 933 zcmZ`%L66c<5H9P|g<|7sAY?Vhi3y>&Y%d ziDwD^k&Oqhn|SnBcs2eA-=oFCx*jH-c{AU1zHjE_j6OM|Ki{}oqbTY+wj8z;HfvhF zd$~sO9|vqYOI=&jr|)jjOlN&-O+TG}PX(b=-zeeGNKMFqsuK>YGWsB@piWwIlk>XDE7y87xkNQCg2B-`N6S0fAPW( zk%LSRHB5hj=#GY_Z};7}0Y>;o{b6q&N~+kBbxGz-%i=BM;<>A^ud51Ie)+0gfeM%& zl%qtMW%e}nX*4-lEYp&My*BKtO(kX%)fu=KU}G6oAzz+Q1wjD9h-D5Q%bGm*K~dX) z!5n5A^Ckt^++c94|Nc35zGCNJ*4<@|_ z8-?xdOjuZ1%F)Ol4bflSqwvC&L@Bb6#XjyVQBQ`7xp1&DRIoA>sM_+3P#2b~DxDeQ4^SbXqNfSZOH0JYQi{ts!gh@NlJ}s7smK)XzexlnE~p!n0!fM~1G`_#y{S^&np?l~Q5RCpvj(0=tu&yYsu9yiX)bwijuX#Q%zvU?FW(jf delta 142 zcmZoTz}9epZGyC*2?GOz6cBR*F(VMiPSi2xF=5cFD&XZ%Vh~{EoR}@o#LBtZP@tBD zr7_NueKIfWRgRL({5%E6VCT)RSff}}w}`8%GB%5sBqrsg7N-_vrWVJiC+4OWBeS_D g3$dk5p2()gW^TbI?yWjmfM2p%gnPRPH{+Wr09yMckN^Mx diff --git a/GamesPassionFR.sqbpro b/GamesPassionFR.sqbpro index bf9d2855..d3c7fb93 100644 --- a/GamesPassionFR.sqbpro +++ b/GamesPassionFR.sqbpro @@ -1 +1 @@ -
+
SELECT * FROM games_in_present
diff --git a/generateJsonFile.mjs b/generateJsonFile.mjs index e453ab2d..77b51d0e 100644 --- a/generateJsonFile.mjs +++ b/generateJsonFile.mjs @@ -11,6 +11,7 @@ const FILES = { "TESTS": "src/app/api/tests/tests.json", "PLATFORMS": "src/app/api/platforms/platforms.json", "GENRES": "src/app/api/genres/genres.json", + "PLANNING": "src/app/api/planning/planning.json" } const db = new Database(databasePath, { @@ -44,4 +45,24 @@ await writeFile( FILES.BACKLOG, JSON.stringify(backlog), "utf-8" -); \ No newline at end of file +); + +// Extract planning +const extractPlanningStmt = db.prepare("SELECT * FROM games_in_future gif INNER JOIN games g ON g.id == gif.id"); +const planning = extractPlanningStmt.all(); +await writeFile( + FILES.PLANNING, + JSON.stringify(planning), + "utf-8" +); + +// Extract games +const extractGamesList = db.prepare("SELECT * FROM games_in_present"); +const gamesList = extractGamesList.all(); +await writeFile( + FILES.GAMES, + JSON.stringify(gamesList), + "utf-8" +); + +// Extract series diff --git a/src/app/api/planning/route.ts b/src/app/api/planning/route.ts index 2dc09339..af3f02af 100644 --- a/src/app/api/planning/route.ts +++ b/src/app/api/planning/route.ts @@ -10,20 +10,10 @@ export type planningEntry = Omit (min !== undefined && max === undefined) || (max !== undefined && elem <= max); - const games = gamesData.filter(game => should_be_displayed(dateAsInteger, game.availableAt as number | undefined, game.endAt as number | undefined)) + const games = (await import("./planning.json")).default; return NextResponse.json(games.map(game => enhanceGameItem(game as BasicGame)), { headers: {