From 87feef3f9631f17e09033b1a959563fdc85b8bae Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Wed, 1 Jun 2022 15:37:26 +0100 Subject: [PATCH] fix: remove legacy code referring to multi-folder showcase-stats --- server/src/lib/showcase/evaluator.test.ts | 19 ------------------- .../games/_game/_playtype/showcase/router.ts | 18 +++++++++--------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/server/src/lib/showcase/evaluator.test.ts b/server/src/lib/showcase/evaluator.test.ts index 9295f7abf..944151341 100644 --- a/server/src/lib/showcase/evaluator.test.ts +++ b/server/src/lib/showcase/evaluator.test.ts @@ -38,25 +38,6 @@ t.test("#EvaluateShowcaseStat", (t) => { t.end(); }); - t.test("Should evaluate a multi-folder stat.", async (t) => { - const data = await EvaluateShowcaseStat( - { - folderID: [TestingIIDXFolderSP10.folderID], - mode: "folder", - property: "lamp", - gte: IIDX_LAMPS.HARD_CLEAR, - }, - 1 - ); - - t.strictSame(data, { - value: 1, - outOf: 1, - }); - - t.end(); - }); - t.test("Should evaluate a chart stat.", async (t) => { const data = await EvaluateShowcaseStat( { diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/showcase/router.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/showcase/router.ts index 520b4b820..db4cb1340 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/showcase/router.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/showcase/router.ts @@ -6,7 +6,7 @@ import { EvaluateUsersStatsShowcase } from "lib/showcase/get-stats"; import p from "prudence"; import { RequirePermissions } from "server/middleware/auth"; import { RequireAuthedAsUser } from "server/router/api/v1/users/_userID/middleware"; -import { GetGamePTConfig } from "tachi-common"; +import { FormatGame, GetGamePTConfig } from "tachi-common"; import { IsRecord } from "utils/misc"; import { FormatPrError } from "utils/prudence"; import { GetUGPT } from "utils/req-tachi-data"; @@ -87,24 +87,24 @@ router.get("/custom", async (req, res) => { }); } - const folderIDs = (req.query.folderID as string).split(","); + const folderID = req.query.folderID as string; - const folders = await db.folders.find({ folderID: { $in: folderIDs } }); + const folder = await db.folders.findOne({ folderID }); - if ( - folders.length !== folderIDs.length || - !folders.every((r) => r.game === game && r.playtype === playtype) - ) { + if (!folder || folder.game !== game || folder.playtype !== playtype) { return res.status(400).json({ success: false, - description: `Invalid folderID - all folders must be for this game, and exist.`, + description: `Invalid folderID - all folders must be for ${FormatGame( + game, + playtype + )}, and exist.`, }); } stat = { mode: "folder", property: req.query.property as "grade" | "lamp" | "percent" | "score", - folderID: folderIDs.length === 1 ? (req.query.folderID as string) : folderIDs, + folderID, gte: Number(req.query.gte), }; } else if (req.query.mode === "chart") {