From e48a5c59d858e8b833a09b540589d35abd59c902 Mon Sep 17 00:00:00 2001 From: zkldi Date: Wed, 26 May 2021 10:46:15 +0100 Subject: [PATCH 1/2] InGameID related DB functions should throw if called for a game that does not support it. Fixes #101 --- server/src/utils/queries/charts.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/utils/queries/charts.ts b/server/src/utils/queries/charts.ts index e2305b893..42e0c04eb 100644 --- a/server/src/utils/queries/charts.ts +++ b/server/src/utils/queries/charts.ts @@ -87,8 +87,10 @@ export function FindChartOnInGameID( playtype: Playtypes[Game], difficulty: Difficulties[IDStrings] ) { - // @todo #101 throw an error if this is called with a game that doesn't - // support InGameID. + if (game === "bms" || game === "usc") { + throw new Error(`Cannot call FindChartOnInGameID for game ${game}.`); + } + return db.charts[game].findOne({ "data.inGameID": inGameID, playtype, @@ -124,8 +126,6 @@ export function FindIIDXChartOnInGameIDVersion( difficulty: Difficulties[IDStrings], version: string ) { - // @todo #101 throw an error if this is called with a game that doesn't - // support InGameID. return db.charts.iidx.findOne({ "data.inGameID": inGameID, "flags.2dxtra": false, From 5e736149baca8533d2685fc7902f7f5c010c0edf Mon Sep 17 00:00:00 2001 From: zkldi Date: Wed, 26 May 2021 11:09:12 +0100 Subject: [PATCH 2/2] Fix bug in FindSDVXChartOnInGameID where INF -> VVD were rejected. --- server/src/utils/queries/charts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/utils/queries/charts.ts b/server/src/utils/queries/charts.ts index 42e0c04eb..00b79e3ea 100644 --- a/server/src/utils/queries/charts.ts +++ b/server/src/utils/queries/charts.ts @@ -170,7 +170,7 @@ export function FindIIDXChartWith2DXtraHash(hash: string) { */ export function FindSDVXChartOnInGameID( inGameID: number, - difficulty: "NOV" | "ADV" | "EXH" | "MXM" | "ANY_INF" + difficulty: Difficulties["sdvx:Single"] | "ANY_INF" ) { const diffQuery = difficulty === "ANY_INF"