From d5218f6d7c71c0efe63f9ac89d1e1cbb1036cf9a Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Tue, 21 Dec 2021 07:20:54 +0000 Subject: [PATCH 1/2] Replace ktRating with ktLampRating as the default IIDX Metric. Fixes #597 --- server/package.json | 2 +- server/pnpm-lock.yaml | 8 +- .../calculated-data/calculated-data.test.ts | 3 - .../calculated-data/calculated-data.ts | 23 +- .../framework/calculated-data/stats.test.ts | 9 +- .../framework/pb/create-pb-doc.test.ts | 7 +- .../lib/score-mutation/update-score.test.ts | 17 +- server/src/lib/score-mutation/update-score.ts | 1 + .../games/_game/_playtype/pbs/router.test.ts | 4 +- .../games/_game/_playtype/router.test.ts | 6 - .../_game/_playtype/sessions/router.test.ts | 2 +- .../_game/_playtype/settings/router.test.ts | 12 +- .../test-utils/mock-db/charts-chunithm.json | 16 +- .../src/test-utils/mock-db/charts-iidx.json | 4 +- .../src/test-utils/mock-db/charts-sdvx.json | 3 +- server/src/test-utils/mock-db/charts-usc.json | 3 +- server/src/test-utils/test-data.ts | 315 ++++++++++++++++-- .../test-data/tachi/chunithm-bbkk-chart.json | 21 -- .../test-data/tachi/chunithm-bbkk-song.json | 11 - .../test-data/tachi/ddr-puty-chart.json | 18 - .../test-data/tachi/ddr-puty-song.json | 12 - .../test-data/tachi/gitadora-dryscore.json | 17 - .../tachi/gitadora-ithinkabtyou.json | 34 -- .../test-data/tachi/iidx-511-song.json | 11 - .../test-data/tachi/iidx-511spa.json | 29 -- .../test-data/tachi/iidx-dryscore.json | 19 -- .../test-data/tachi/iidx-score.json | 35 -- .../test-data/tachi/iidx-scorepb.json | 38 --- .../test-data/tachi/sdvx-albida-chart.json | 22 -- .../test-data/tachi/sdvx-albida-song.json | 13 - .../test-data/tachi/sdvx-dryscore.json | 17 - 31 files changed, 348 insertions(+), 384 deletions(-) delete mode 100644 server/src/test-utils/test-data/tachi/chunithm-bbkk-chart.json delete mode 100644 server/src/test-utils/test-data/tachi/chunithm-bbkk-song.json delete mode 100644 server/src/test-utils/test-data/tachi/ddr-puty-chart.json delete mode 100644 server/src/test-utils/test-data/tachi/ddr-puty-song.json delete mode 100644 server/src/test-utils/test-data/tachi/gitadora-dryscore.json delete mode 100644 server/src/test-utils/test-data/tachi/gitadora-ithinkabtyou.json delete mode 100644 server/src/test-utils/test-data/tachi/iidx-511-song.json delete mode 100644 server/src/test-utils/test-data/tachi/iidx-511spa.json delete mode 100644 server/src/test-utils/test-data/tachi/iidx-dryscore.json delete mode 100644 server/src/test-utils/test-data/tachi/iidx-score.json delete mode 100644 server/src/test-utils/test-data/tachi/iidx-scorepb.json delete mode 100644 server/src/test-utils/test-data/tachi/sdvx-albida-chart.json delete mode 100644 server/src/test-utils/test-data/tachi/sdvx-albida-song.json delete mode 100644 server/src/test-utils/test-data/tachi/sdvx-dryscore.json diff --git a/server/package.json b/server/package.json index 340221433..ad3099822 100644 --- a/server/package.json +++ b/server/package.json @@ -83,7 +83,7 @@ "rimraf": "3.0.2", "safe-json-stringify": "1.2.0", "seq-logging": "^1.1.1", - "tachi-common": "0.3.22", + "tachi-common": "0.3.24", "ts-node": "10.0.0", "typescript": "4.3.4", "winston": "3.3.3", diff --git a/server/pnpm-lock.yaml b/server/pnpm-lock.yaml index 8bea94550..bff659924 100644 --- a/server/pnpm-lock.yaml +++ b/server/pnpm-lock.yaml @@ -63,7 +63,7 @@ specifiers: safe-json-stringify: 1.2.0 seq-logging: ^1.1.1 supertest: 6.1.3 - tachi-common: 0.3.22 + tachi-common: 0.3.24 tap: 15.0.9 ts-node: 10.0.0 tsconfig-paths: 3.10.1 @@ -107,7 +107,7 @@ dependencies: rimraf: 3.0.2 safe-json-stringify: 1.2.0 seq-logging: 1.1.1 - tachi-common: 0.3.22 + tachi-common: 0.3.24 ts-node: 10.0.0_83f53b0a0c5616d3fa00ed4e30b9ce1b typescript: 4.3.4 winston: 3.3.3 @@ -5387,8 +5387,8 @@ packages: strip-ansi: 6.0.0 dev: true - /tachi-common/0.3.22: - resolution: {integrity: sha512-nLt1wv65wY5WdB/QXuVNeOOgA8r2c8OrohGEKyylE5wRyWIA8wOVsZJGPxi9Uxm0TqeVDXwBRV8CyV97czZAMA==} + /tachi-common/0.3.24: + resolution: {integrity: sha512-nTfVZeRXqOyVF5viHACawbbrERzwyY88wBxNuhpZVvSL4jTjFy7dSRf/7LnJVDC1XizhUBKfYMlOBXOUXTIzzg==} dependencies: monk: 7.3.4 transitivePeerDependencies: diff --git a/server/src/lib/score-import/framework/calculated-data/calculated-data.test.ts b/server/src/lib/score-import/framework/calculated-data/calculated-data.test.ts index ebdaf6ab3..108a76ed9 100644 --- a/server/src/lib/score-import/framework/calculated-data/calculated-data.test.ts +++ b/server/src/lib/score-import/framework/calculated-data/calculated-data.test.ts @@ -20,7 +20,6 @@ t.test("#CreateCalculatedData", async (t) => { prAssert( res, { - ktRating: p.aprx(2.65), ktLampRating: p.equalTo(10), BPI: "?number", }, @@ -85,7 +84,6 @@ t.test("#CalculateDataForGamePT", (t) => { prAssert( res, { - ktRating: "?number", ktLampRating: "?number", BPI: "?number", }, @@ -109,7 +107,6 @@ t.test("#CalculateDataForGamePT", (t) => { prAssert( res, { - ktRating: "?number", ktLampRating: "?number", BPI: "?number", }, diff --git a/server/src/lib/score-import/framework/calculated-data/calculated-data.ts b/server/src/lib/score-import/framework/calculated-data/calculated-data.ts index f435805ff..3e86cb76d 100644 --- a/server/src/lib/score-import/framework/calculated-data/calculated-data.ts +++ b/server/src/lib/score-import/framework/calculated-data/calculated-data.ts @@ -149,7 +149,6 @@ async function CalculateDataIIDXSP( return { BPI: bpi, - ktRating: CalculateKTRating(dryScore, "iidx", "SP", chart, logger), ktLampRating: CalculateKTLampRatingIIDX(dryScore, "SP", chart as ChartDocument<"iidx:SP">), }; } @@ -181,7 +180,6 @@ async function CalculateDataIIDXDP( return { BPI: bpi, - ktRating: CalculateKTRating(dryScore, "iidx", "DP", chart, logger), ktLampRating: CalculateKTLampRatingIIDX(dryScore, "DP", chart as ChartDocument<"iidx:DP">), }; } @@ -267,8 +265,25 @@ export function CalculateDataBMS14K( chart: ChartDocument, logger: KtLogger ): CalculatedData<"bms:14K"> { + const ecValue = chart.tierlistInfo["sgl-EC"]?.value ?? 0; + const hcValue = chart.tierlistInfo["sgl-HC"]?.value ?? 0; + + const gptConfig = GetGamePTConfig("bms", "7K"); + + const lampIndex = gptConfig.lamps.indexOf(dryScore.scoreData.lamp); + + if (lampIndex >= IIDX_LAMPS.HARD_CLEAR) { + return { + sieglinde: Math.max(hcValue, ecValue), + }; + } else if (lampIndex >= IIDX_LAMPS.EASY_CLEAR) { + return { + sieglinde: ecValue, + }; + } + return { - sieglinde: 0, // @todo #33 + sieglinde: 0, }; } @@ -286,7 +301,7 @@ export function CalculateDataBMS7K( if (lampIndex >= IIDX_LAMPS.HARD_CLEAR) { return { - sieglinde: Math.max(hcValue, ecValue), // @todo #33 + sieglinde: Math.max(hcValue, ecValue), }; } else if (lampIndex >= IIDX_LAMPS.EASY_CLEAR) { return { diff --git a/server/src/lib/score-import/framework/calculated-data/stats.test.ts b/server/src/lib/score-import/framework/calculated-data/stats.test.ts index a30293fc1..0b6ba2888 100644 --- a/server/src/lib/score-import/framework/calculated-data/stats.test.ts +++ b/server/src/lib/score-import/framework/calculated-data/stats.test.ts @@ -3,7 +3,12 @@ import CreateLogCtx from "lib/logger/logger"; import { ChartDocument, Difficulties, Lamps, ScoreDocument } from "tachi-common"; import t from "tap"; import { isApproximately } from "test-utils/asserts"; -import { GetKTDataJSON, Testing511SPA, TestingIIDXSPDryScore } from "test-utils/test-data"; +import { + CHUNITHMBBKKChart, + GetKTDataJSON, + Testing511SPA, + TestingIIDXSPDryScore, +} from "test-utils/test-data"; import { DryScore } from "../common/types"; import { CalculateBPI, @@ -339,7 +344,7 @@ t.test("#CalculateMFCP", (t) => { t.end(); }); -const bbkk = GetKTDataJSON("./tachi/chunithm-bbkk-chart.json"); +const bbkk = CHUNITHMBBKKChart; // unit testing a mathematical function is a square-round-hole problem. t.test("#CalculateCHUNITHMRating", (t) => { diff --git a/server/src/lib/score-import/framework/pb/create-pb-doc.test.ts b/server/src/lib/score-import/framework/pb/create-pb-doc.test.ts index 61546bc80..61072a0ee 100644 --- a/server/src/lib/score-import/framework/pb/create-pb-doc.test.ts +++ b/server/src/lib/score-import/framework/pb/create-pb-doc.test.ts @@ -7,7 +7,7 @@ import ResetDBState from "test-utils/resets"; import { GetKTDataJSON, Testing511SPA, TestingIIDXSPScore } from "test-utils/test-data"; import { CreatePBDoc } from "./create-pb-doc"; -let IIDXScore = TestingIIDXSPScore; +const IIDXScore = TestingIIDXSPScore; const logger = CreateLogCtx(__filename); @@ -15,10 +15,6 @@ const lamps = GetGamePTConfig("iidx", "SP").lamps; t.test("#CreatePBDoc", (t) => { t.beforeEach(ResetDBState); - t.beforeEach(() => { - // monk adds _id onto the file when you import it, so lets try and avoid that - IIDXScore = GetKTDataJSON("./tachi/iidx-score.json"); - }); const chartID = Testing511SPA.chartID; @@ -48,7 +44,6 @@ t.test("#CreatePBDoc", (t) => { hitMeta: { bp: 1 }, }, calculatedData: { - ktRating: IIDXScore.calculatedData.ktRating, ktLampRating: 12, }, }; diff --git a/server/src/lib/score-mutation/update-score.test.ts b/server/src/lib/score-mutation/update-score.test.ts index ba8d96d67..79a28c6b9 100644 --- a/server/src/lib/score-mutation/update-score.test.ts +++ b/server/src/lib/score-mutation/update-score.test.ts @@ -6,6 +6,7 @@ import db from "external/mongo/db"; import UpdateScore from "./update-score"; import { CreateScoreID } from "lib/score-import/framework/score-importing/score-id"; import ResetDBState from "test-utils/resets"; +import { rootLogger } from "lib/logger/logger"; const mockImportDocument: ImportDocument = { userID: 1, @@ -18,7 +19,7 @@ const mockImportDocument: ImportDocument = { importID: "mockImportID", importType: "file/batch-manual", milestoneInfo: [], - scoreIDs: ["scoreid_1", "scoreid_2"], + scoreIDs: ["TESTING_SCORE_ID", "scoreid_2"], timeFinished: 1000, timeStarted: 0, game: "iidx", @@ -37,7 +38,7 @@ const mockSessionDocument: SessionDocument = { scoreInfo: [ { isNewScore: true, - scoreID: "scoreid_1", + scoreID: "TESTING_SCORE_ID", }, { isNewScore: true, @@ -55,7 +56,9 @@ t.test("#UpdateScore", (t) => { t.beforeEach(ResetDBState); t.test("Should update a score and everything pertaining to it", async (t) => { - TestingIIDXSPScore.scoreID = "scoreid_1"; + // n.b. this must be here!! otherwise we get nonsense errors due to _id bson + // errors. + delete TestingIIDXSPScore._id; const score = deepmerge(TestingIIDXSPScore, { scoreData: { score: 1020 }, @@ -66,8 +69,6 @@ t.test("#UpdateScore", (t) => { await db.imports.insert(mockImportDocument); await db.sessions.insert(mockSessionDocument); - await db.scores.insert(TestingIIDXSPScore); - // This function doesn't return anything, instead, // we need to check external state. await UpdateScore(TestingIIDXSPScore, score); @@ -82,6 +83,8 @@ t.test("#UpdateScore", (t) => { scoreID: newScoreID, }); + rootLogger.crit("foo", await db.scores.find({})); + t.hasStrict( dbNewScore?.scoreData, score.scoreData, @@ -95,7 +98,7 @@ t.test("#UpdateScore", (t) => { t.strictSame( dbImport?.scoreIDs, [newScoreID, "scoreid_2"], - "Should update scoreid_1 to the new hash." + "Should update TESTING_SCORE_ID to the new hash." ); const dbSession = await db.sessions.findOne({ @@ -114,7 +117,7 @@ t.test("#UpdateScore", (t) => { scoreID: "scoreid_2", }, ], - "Should update scoreid_1 to the new hash." + "Should update TESTING_SCORE_ID to the new hash." ); t.end(); diff --git a/server/src/lib/score-mutation/update-score.ts b/server/src/lib/score-mutation/update-score.ts index f2f0f4f0c..cf44c4be7 100644 --- a/server/src/lib/score-mutation/update-score.ts +++ b/server/src/lib/score-mutation/update-score.ts @@ -74,6 +74,7 @@ export default async function UpdateScore(oldScore: ScoreDocument, newScore: Sco { $set: newScore } ); } catch (err) { + logger.error(err); logger.warn( `Score ID ${newScoreID} already existed -- this update caused a collision. Removing old score and updating old references anyway.` ); diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts index 9b00e7038..5b7d1aea9 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts @@ -14,7 +14,7 @@ import { t.test("GET /api/v1/users/:userID/games/:game/:playtype/pbs/best", (t) => { t.beforeEach(ResetDBState); - t.test("Should return a users best 100 personal bests.", async (t) => { + t.test("Should return a user's best 100 personal bests.", async (t) => { const mockPBs: PBScoreDocument[] = []; for (let i = 0; i < 200; i++) { @@ -26,7 +26,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/pbs/best", (t) => { chartID: i.toString(), // hack to generate some random chartIDs songID: Testing511Song.id, calculatedData: { - ktRating: i, + ktLampRating: i, }, } as PBScoreDocument); } diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.test.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.test.ts index 470635cdd..3cb3f5f5d 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/router.test.ts @@ -33,7 +33,6 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype", (t) => { mostRecentScore: null, totalScores: 1, rankingData: { - ktRating: { ranking: 1, outOf: 1 }, ktLampRating: { ranking: 1, outOf: 1, @@ -97,7 +96,6 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype", (t) => { }, totalScores: 4, rankingData: { - ktRating: { ranking: 1, outOf: 1 }, ktLampRating: { ranking: 1, outOf: 1, @@ -147,10 +145,6 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/history", (t) => { t.strictSame(res.body.body, [ { rankings: { - ktRating: { - ranking: 1, - outOf: 1, - }, ktLampRating: { ranking: 1, outOf: 1, diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.test.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.test.ts index f6d76180e..a4e9eb2bb 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.test.ts @@ -81,7 +81,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/sessions/best", (t) => { playtype: "SP", userID: 1, calculatedData: { - ktRating: i, + ktLampRating: i, }, } as SessionDocument); } diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/settings/router.test.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/settings/router.test.ts index ab14daedd..19c14ed5b 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/settings/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/settings/router.test.ts @@ -50,7 +50,7 @@ t.test("PATCH /api/v1/users/:userID/games/:game/:playtype/settings", (t) => { .patch("/api/v1/users/1/games/iidx/SP/settings") .set("Authorization", "Bearer api_token") .send({ - preferredScoreAlg: "ktRating", + preferredScoreAlg: "ktLampRating", }); t.strictSame( @@ -60,7 +60,7 @@ t.test("PATCH /api/v1/users/:userID/games/:game/:playtype/settings", (t) => { game: "iidx", playtype: "SP", preferences: { - preferredScoreAlg: "ktRating", + preferredScoreAlg: "ktLampRating", preferredSessionAlg: null, preferredProfileAlg: null, scoreBucket: null, @@ -79,7 +79,7 @@ t.test("PATCH /api/v1/users/:userID/games/:game/:playtype/settings", (t) => { playtype: "SP", }); - t.equal(data?.preferences.preferredScoreAlg, "ktRating"); + t.equal(data?.preferences.preferredScoreAlg, "ktLampRating"); t.end(); }); @@ -99,7 +99,7 @@ t.test("PATCH /api/v1/users/:userID/games/:game/:playtype/settings", (t) => { .patch("/api/v1/users/1/games/iidx/SP/settings") .set("Authorization", "Bearer api_token") .send({ - preferredScoreAlg: "ktRating", + preferredScoreAlg: "ktLampRating", gameSpecific: { display2DXTra: true, }, @@ -112,7 +112,7 @@ t.test("PATCH /api/v1/users/:userID/games/:game/:playtype/settings", (t) => { game: "iidx", playtype: "SP", preferences: { - preferredScoreAlg: "ktRating", + preferredScoreAlg: "ktLampRating", preferredSessionAlg: null, preferredProfileAlg: null, scoreBucket: null, @@ -131,7 +131,7 @@ t.test("PATCH /api/v1/users/:userID/games/:game/:playtype/settings", (t) => { playtype: "SP", }); - t.equal(data?.preferences.preferredScoreAlg, "ktRating"); + t.equal(data?.preferences.preferredScoreAlg, "ktLampRating"); t.end(); }); diff --git a/server/src/test-utils/mock-db/charts-chunithm.json b/server/src/test-utils/mock-db/charts-chunithm.json index 4c19616a8..d0ed429df 100644 --- a/server/src/test-utils/mock-db/charts-chunithm.json +++ b/server/src/test-utils/mock-db/charts-chunithm.json @@ -7,25 +7,13 @@ "playtype": "Single", "levelNum": 3, "level": "3", - "flags": { - "IN BASE GAME": true, - "OMNIMIX": true - }, "data": { "inGameID": 3 }, + "tierlistInfo": {}, "isPrimary": true, "versions": [ - "chuni", - "chuniplus", - "air", - "airplus", - "star", - "starplus", - "amazon", - "amazonplus", - "crystal", - "crystalplus" + "paradiselost" ] } ] \ No newline at end of file diff --git a/server/src/test-utils/mock-db/charts-iidx.json b/server/src/test-utils/mock-db/charts-iidx.json index 72d6a17ad..d1f748cec 100644 --- a/server/src/test-utils/mock-db/charts-iidx.json +++ b/server/src/test-utils/mock-db/charts-iidx.json @@ -11,7 +11,9 @@ "data": { "inGameID": 1000, "notecount": 786, - "arcChartID": "CYjwAuz7Yq9" + "arcChartID": "CYjwAuz7Yq9", + "2dxtraSet": null, + "hashSHA256": null }, "isPrimary": true, "versions": [ diff --git a/server/src/test-utils/mock-db/charts-sdvx.json b/server/src/test-utils/mock-db/charts-sdvx.json index 98e1f850e..9195fd563 100644 --- a/server/src/test-utils/mock-db/charts-sdvx.json +++ b/server/src/test-utils/mock-db/charts-sdvx.json @@ -19,6 +19,7 @@ "heaven", "vivid", "konaste" - ] + ], + "tierlistInfo": {} } ] \ No newline at end of file diff --git a/server/src/test-utils/mock-db/charts-usc.json b/server/src/test-utils/mock-db/charts-usc.json index b362f266b..24f05e895 100644 --- a/server/src/test-utils/mock-db/charts-usc.json +++ b/server/src/test-utils/mock-db/charts-usc.json @@ -14,6 +14,7 @@ "hashSHA1": "USC_CHART_HASH" }, "isPrimary": true, - "versions": [] + "versions": [], + "tierlistInfo": {} } ] \ No newline at end of file diff --git a/server/src/test-utils/test-data.ts b/server/src/test-utils/test-data.ts index 6d792f0d2..493368284 100644 --- a/server/src/test-utils/test-data.ts +++ b/server/src/test-utils/test-data.ts @@ -30,18 +30,123 @@ const file = (name: string) => path.join(__dirname, "/test-data", name); export const GetKTDataJSON = (name: string) => JSON.parse(fs.readFileSync(file(name), "utf-8")); export const GetKTDataBuffer = (name: string) => fs.readFileSync(file(name)); -export const TestingIIDXSPDryScore = GetKTDataJSON( - "./tachi/iidx-dryscore.json" -) as DryScore<"iidx:SP">; +export const TestingIIDXSPDryScore: DryScore<"iidx:SP"> = { + service: "e-amusement", + game: "iidx", + scoreData: { + score: 786, + lamp: "CLEAR", + percent: 50, + grade: "C", + judgements: { + pgreat: 50, + great: 10, + }, + hitMeta: {}, + }, + scoreMeta: {}, + timeAchieved: null, + comment: null, + importType: "file/eamusement-iidx-csv", +}; -export const TestingIIDXSPScorePB = GetKTDataJSON( - "./tachi/iidx-scorepb.json" -) as PBScoreDocument<"iidx:SP">; -export const TestingIIDXSPScore = GetKTDataJSON( - "./tachi/iidx-score.json" -) as ScoreDocument<"iidx:SP">; +export const TestingIIDXSPScorePB: PBScoreDocument<"iidx:SP"> = { + chartID: "c2311194e3897ddb5745b1760d2c0141f933e683", + userID: 1, + calculatedData: { + ktLampRating: 0, + BPI: 10.1, + }, + composedFrom: { + scorePB: "TESTING_SCORE_ID", + lampPB: "TESTING_SCORE_ID", + }, + highlight: false, + isPrimary: true, + scoreData: { + score: 1479, + percent: 94.08396946564885, + esd: 10.64453125, + grade: "AAA", + gradeIndex: 7, + lamp: "EX HARD CLEAR", + lampIndex: 6, + judgements: { + pgreat: 697, + great: 85, + }, + hitMeta: { + bp: 2, + }, + }, + rankingData: { + rank: 1, + outOf: 2, + }, + songID: 1, + game: "iidx", + playtype: "SP", + timeAchieved: 10000, +}; -export const TestingKsHookSV3CScore = GetKTDataJSON("./kshook-sv3c/base.json") as KsHookSV3CScore; +export const TestingIIDXSPScore: ScoreDocument<"iidx:SP"> = { + service: "foo (DIRECT-MANUAL)", + game: "iidx", + playtype: "SP", + userID: 1, + scoreData: { + score: 786, + lamp: "CLEAR", + percent: 50, + grade: "C", + esd: 30, + gradeIndex: 3, + lampIndex: 4, + judgements: { + pgreat: 50, + great: 10, + }, + hitMeta: {}, + }, + scoreMeta: {}, + calculatedData: { + ktLampRating: 5, + }, + timeAchieved: 1619454485988, + songID: 1, + chartID: "c2311194e3897ddb5745b1760d2c0141f933e683", + highlight: false, + isPrimary: true, + comment: null, + timeAdded: 1, + scoreID: "TESTING_SCORE_ID", + importType: "ir/direct-manual", +}; + +export const TestingKsHookSV3CScore: KsHookSV3CScore = { + appeal_id: 2001, + btn_rate: 182, + clear: "CLEAR_EXCESSIVE", + critical: 1184, + difficulty: "DIFFICULTY_ADVANCED", + early: 36, + error: 30, + gauge: 71, + grade: "GRADE_AA_PLUS", + late: 10, + long_rate: 195, + max_chain: 158, + music_id: 1, + near: 46, + player_name: "EE", + rate: "RATE_EXCESSIVE", + score: 9579365, + skill_frame: "SKILL_FRAME_NONE", + skill_level: "SKILL_LEVEL_NONE", + skill_name: 5, + track_no: 0, + vol_rate: 193, +}; export const TestingLR2HookScore: LR2HookScore = { md5: "38616b85332037cc12924f2ae2840262", @@ -67,29 +172,167 @@ export const TestingLR2HookScore: LR2HookScore = { }, }; -export const Testing511SPA = GetKTDataJSON("./tachi/iidx-511spa.json") as ChartDocument<"iidx:SP">; +export const Testing511SPA: ChartDocument<"iidx:SP"> = { + rgcID: null, + chartID: "c2311194e3897ddb5745b1760d2c0141f933e683", + difficulty: "ANOTHER", + songID: 1, + playtype: "SP", + levelNum: 10, + level: "10", + data: { + inGameID: 1000, + notecount: 786, + arcChartID: "CYjwAuz7Yq9", + "2dxtraSet": null, + hashSHA256: null, + }, + tierlistInfo: {}, + isPrimary: true, + versions: [ + "27-omni", + "26-omni", + "27", + "26", + "inf", + "16-cs", + "12-cs", + "10-cs", + "8-cs", + "7-cs", + "bmus", + ], +}; -export const Testing511Song = GetKTDataJSON("./tachi/iidx-511-song.json") as SongDocument<"iidx">; +export const Testing511Song: SongDocument<"iidx"> = { + title: "5.1.1.", + artist: "dj nagureo", + id: 1, + altTitles: [], + searchTerms: [], + data: { + genre: "PIANO AMBIENT", + displayVersion: "1", + }, +}; -export const TestingAlbidaADV = GetKTDataJSON( - "./tachi/sdvx-albida-chart.json" -) as ChartDocument<"sdvx:Single">; +export const TestingAlbidaADV: ChartDocument<"sdvx:Single"> = { + rgcID: null, + chartID: "5088a4d0e1ee9d0cc2f625934306e45b1a60699b", + difficulty: "ADV", + songID: 1, + playtype: "Single", + levelNum: 10, + level: "10", + data: { + inGameID: 1, + arcChartID: "EOZ7FixCDpv", + }, + isPrimary: true, + versions: ["booth", "inf", "gw", "heaven", "vivid", "konaste"], + tierlistInfo: {}, +}; -export const TestingSDVXAlbidaSong = GetKTDataJSON( - "./tachi/sdvx-albida-song.json" -) as SongDocument<"sdvx">; +export const BMSGazerChart: ChartDocument<"bms:7K"> = { + songID: 27339, + chartID: "88eb6cc5683e2740cbd07f588a5f3db1db8d467b", + rgcID: null, + data: { + notecount: 2256, + hashMD5: "38616b85332037cc12924f2ae2840262", + hashSHA256: "195fe1be5c3e74fccd04dc426e05f8a9cfa8a1059c339d0a23e99f63661f0b7d", + tableFolders: [ + { + level: "17", + table: "★", + }, + ], + }, + level: "?", + levelNum: 0, + difficulty: "CHART", + playtype: "7K", + isPrimary: true, + versions: [], + tierlistInfo: {}, +}; -export const TestingDoraChart = GetKTDataJSON( - "./tachi/gitadora-ithinkabtyou.json" -) as ChartDocument<"gitadora:Dora">; +export const CHUNITHMBBKKChart: ChartDocument<"chunithm:Single"> = { + rgcID: null, + chartID: "192b96bdb6150f80ba6412ce02df1249e16c0cb0", + difficulty: "BASIC", + songID: 3, + playtype: "Single", + levelNum: 3, + level: "3", + data: { + inGameID: 3, + }, + tierlistInfo: {}, + isPrimary: true, + versions: ["paradiselost"], +}; -export const TestingSDVXSingleDryScore = GetKTDataJSON( - "./tachi/sdvx-dryscore.json" -) as DryScore<"sdvx:Single">; +export const TestingSDVXAlbidaSong: SongDocument<"sdvx"> = { + title: "ALBIDA Powerless Mix", + artist: "無力P", + id: 1, + altTitles: [], + searchTerms: ["albida_muryoku", "アルビダパワーレスミックス"], + data: { + displayVersion: "booth", + }, +}; -export const TestingGITADORADoraDryScore = GetKTDataJSON( - "./tachi/gitadora-dryscore.json" -) as DryScore<"gitadora:Dora">; +export const TestingDoraChart: ChartDocument<"gitadora:Dora"> = { + songID: 0, + chartID: "29f0bfab357ba54e3fd0176fb3cbc578c9ec8df5", + difficulty: "BASIC", + playtype: "Dora", + levelNum: 1.6, + level: "1.60", + data: { + inGameID: 0, + }, + isPrimary: true, + rgcID: null, + tierlistInfo: {}, + versions: ["nextage"], +}; + +export const TestingSDVXSingleDryScore: DryScore<"sdvx:Single"> = { + service: "e-amusement", + game: "sdvx", + scoreData: { + score: 95000000, + lamp: "EXCESSIVE CLEAR", + percent: 95, + grade: "AA+", + judgements: {}, + hitMeta: {}, + }, + scoreMeta: {}, + timeAchieved: null, + comment: null, + importType: "file/batch-manual", +}; + +export const TestingGITADORADoraDryScore: DryScore<"gitadora:Dora"> = { + service: "fake-service", + game: "gitadora", + scoreData: { + score: 70.76, + lamp: "CLEAR", + percent: 70.76, + grade: "B", + judgements: {}, + hitMeta: {}, + }, + scoreMeta: {}, + timeAchieved: null, + comment: null, + importType: "file/batch-manual", +}; export const TestingIIDXEamusementCSV26 = GetKTDataBuffer( "./eamusement-iidx-csv/pre-leggendaria.csv" @@ -102,7 +345,23 @@ export const TestingSDVXEamusementCSV = GetKTDataBuffer( "./eamusement-sdvx-csv/exceed-gear-score.csv" ); -export const TestingBarbatosScore: BarbatosScore = GetKTDataJSON("./barbatos/base.json"); +export const TestingBarbatosScore: BarbatosScore = { + difficulty: 1, + level: 10, + song_id: 1, + max_chain: 50, + critical: 50, + near_total: 30, + near_fast: 20, + near_slow: 10, + score: 9500000, + error: 5, + percent: 81, + did_fail: false, + clear_type: 2, + gauge_type: 1, + is_skill_analyzer: false, +}; export const HC511Goal: GoalDocument = { charts: { diff --git a/server/src/test-utils/test-data/tachi/chunithm-bbkk-chart.json b/server/src/test-utils/test-data/tachi/chunithm-bbkk-chart.json deleted file mode 100644 index 17535905a..000000000 --- a/server/src/test-utils/test-data/tachi/chunithm-bbkk-chart.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "rgcID": null, - "chartID": "192b96bdb6150f80ba6412ce02df1249e16c0cb0", - "difficulty": "BASIC", - "songID": 3, - "playtype": "Single", - "levelNum": 3, - "level": "3", - "flags": { - "IN BASE GAME": true, - "OMNIMIX": true - }, - "data": { - "inGameID": 3 - }, - "isPrimary": true, - "versions": [ - "crystal", - "crystalplus" - ] -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/chunithm-bbkk-song.json b/server/src/test-utils/test-data/tachi/chunithm-bbkk-song.json deleted file mode 100644 index 08124ebde..000000000 --- a/server/src/test-utils/test-data/tachi/chunithm-bbkk-song.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "title": "B.B.K.K.B.K.K.", - "artist": "nora2r", - "id": 3, - "altTitles": [], - "searchTerms": [], - "data": { - "genre": "VARIETY", - "displayVersion": "chuni" - } -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/ddr-puty-chart.json b/server/src/test-utils/test-data/tachi/ddr-puty-chart.json deleted file mode 100644 index c5aec5879..000000000 --- a/server/src/test-utils/test-data/tachi/ddr-puty-chart.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "rgcID": null, - "chartID": "48024d36bbe76c9fed09c3ffdc19412925d1efd3", - "difficulty": "DIFFICULT", - "songID": 10, - "playtype": "SP", - "levelNum": 6, - "level": "6", - "data": { - "inGameID": "puty", - "songHash": "DQlQ1DlPbq900oqdOo8l0d6I1lIOl99l", - "arcChartID": "BD_uIVl5USj" - }, - "isPrimary": true, - "versions": [ - "a" - ] -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/ddr-puty-song.json b/server/src/test-utils/test-data/tachi/ddr-puty-song.json deleted file mode 100644 index c1d55ef72..000000000 --- a/server/src/test-utils/test-data/tachi/ddr-puty-song.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "title": "PUT YOUR FAITH IN ME", - "artist": "UZI-LAY", - "id": 10, - "altTitles": [], - "searchTerms": [ - "putyourfaithinme" - ], - "data": { - "displayVersion": "2" - } -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/gitadora-dryscore.json b/server/src/test-utils/test-data/tachi/gitadora-dryscore.json deleted file mode 100644 index 439d3b226..000000000 --- a/server/src/test-utils/test-data/tachi/gitadora-dryscore.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "service": "fake-service", - "game": "gitadora", - "scoreData": { - "score": 70.76, - "lamp": "CLEAR", - "percent": 70.76, - "grade": "B", - "esd": 30, - "judgements": {}, - "hitMeta": {} - }, - "scoreMeta": {}, - "timeAchieved": null, - "comment": null, - "importType": "file/batch-manual" -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/gitadora-ithinkabtyou.json b/server/src/test-utils/test-data/tachi/gitadora-ithinkabtyou.json deleted file mode 100644 index 328fb95ae..000000000 --- a/server/src/test-utils/test-data/tachi/gitadora-ithinkabtyou.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "id": 0, - "chartID": "29f0bfab357ba54e3fd0176fb3cbc578c9ec8df5", - "difficulty": "BASIC", - "playtype": "Dora", - "levelNum": 1.6, - "level": "1.60", - "notedata": { - "notecount": 169, - "objects": { - "LEFT CYMBAL": 54, - "HI HAT": 78, - "LEFT PEDAL": 24, - "SNARE": 1, - "HI TOM": 1, - "RIGHT PEDAL": 2, - "LOW TOM": 4, - "FLOOR TOM": 5, - "RIGHT CYMBAL": 0 - } - }, - "length": null, - "bpmMin": 117, - "bpmMax": 117, - "monoBPM": true, - "indicators": {}, - "flags": { - "IN BASE GAME": true - }, - "internals": { - "inGameID": "0", - "inGameINTID": 0 - } -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/iidx-511-song.json b/server/src/test-utils/test-data/tachi/iidx-511-song.json deleted file mode 100644 index 7f10c6c58..000000000 --- a/server/src/test-utils/test-data/tachi/iidx-511-song.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "title": "5.1.1.", - "artist": "dj nagureo", - "id": 1, - "altTitles": [], - "searchTerms": [], - "data": { - "genre": "PIANO AMBIENT", - "displayVersion": "1" - } -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/iidx-511spa.json b/server/src/test-utils/test-data/tachi/iidx-511spa.json deleted file mode 100644 index f96ccbc0f..000000000 --- a/server/src/test-utils/test-data/tachi/iidx-511spa.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "rgcID": null, - "chartID": "c2311194e3897ddb5745b1760d2c0141f933e683", - "difficulty": "ANOTHER", - "songID": 1, - "playtype": "SP", - "levelNum": 10, - "level": "10", - "data": { - "inGameID": 1000, - "notecount": 786, - "arcChartID": "CYjwAuz7Yq9" - }, - "tierlistInfo": {}, - "isPrimary": true, - "versions": [ - "27-omni", - "26-omni", - "27", - "26", - "inf", - "16-cs", - "12-cs", - "10-cs", - "8-cs", - "7-cs", - "bmus" - ] -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/iidx-dryscore.json b/server/src/test-utils/test-data/tachi/iidx-dryscore.json deleted file mode 100644 index 1270e9c2f..000000000 --- a/server/src/test-utils/test-data/tachi/iidx-dryscore.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "service": "e-amusement", - "game": "iidx", - "scoreData": { - "score": 786, - "lamp": "CLEAR", - "percent": 50, - "grade": "C", - "judgements": { - "pgreat": 50, - "great": 10 - }, - "hitMeta": {} - }, - "scoreMeta": {}, - "timeAchieved": null, - "comment": null, - "importType": "iidx:eamusement-csv" -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/iidx-score.json b/server/src/test-utils/test-data/tachi/iidx-score.json deleted file mode 100644 index 898acf560..000000000 --- a/server/src/test-utils/test-data/tachi/iidx-score.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "service": "foo (DIRECT-MANUAL)", - "game": "iidx", - "playtype": "SP", - "difficulty": "ANOTHER", - "userID": 1, - "scoreData": { - "score": 786, - "lamp": "CLEAR", - "percent": 50, - "grade": "C", - "esd": 30, - "gradeIndex": 3, - "lampIndex": 4, - "judgements": { - "pgreat": 50, - "great": 10 - }, - "hitMeta": {} - }, - "scoreMeta": {}, - "calculatedData": { - "ktRating": 0.1, - "ktLampRating": 5 - }, - "timeAchieved": 1619454485988, - "songID": 1, - "chartID": "c2311194e3897ddb5745b1760d2c0141f933e683", - "highlight": false, - "isPrimary": true, - "comment": null, - "timeAdded": 1, - "scoreID": "TESTING_SCORE_ID", - "importType": "ir/direct-manual" -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/iidx-scorepb.json b/server/src/test-utils/test-data/tachi/iidx-scorepb.json deleted file mode 100644 index 435f6f792..000000000 --- a/server/src/test-utils/test-data/tachi/iidx-scorepb.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "chartID": "c2311194e3897ddb5745b1760d2c0141f933e683", - "userID": 1, - "calculatedData": { - "ktRating": 0, - "ktLampRating": 0, - "BPI": 10.10 - }, - "composedFrom": { - "scorePB": "TESTING_SCORE_ID", - "lampPB": "TESTING_SCORE_ID" - }, - "highlight": false, - "isPrimary": true, - "scoreData": { - "score": 1479, - "percent": 94.08396946564885, - "esd": 10.64453125, - "grade": "AAA", - "gradeIndex": 7, - "lamp": "EX HARD CLEAR", - "lampIndex": 6, - "judgements": { - "pgreat": 697, - "great": 85 - }, - "hitMeta": { - "bp": 2 - } - }, - "rankingData": { - "rank": 1, - "outOf": 2 - }, - "songID": 1, - "game": "iidx", - "playtype": "SP" -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/sdvx-albida-chart.json b/server/src/test-utils/test-data/tachi/sdvx-albida-chart.json deleted file mode 100644 index 327cdd34a..000000000 --- a/server/src/test-utils/test-data/tachi/sdvx-albida-chart.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "rgcID": null, - "chartID": "5088a4d0e1ee9d0cc2f625934306e45b1a60699b", - "difficulty": "ADV", - "songID": 1, - "playtype": "Single", - "levelNum": 10, - "level": "10", - "data": { - "inGameID": 1, - "arcChartID": "EOZ7FixCDpv" - }, - "isPrimary": true, - "versions": [ - "booth", - "inf", - "gw", - "heaven", - "vivid", - "konaste" - ] -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/sdvx-albida-song.json b/server/src/test-utils/test-data/tachi/sdvx-albida-song.json deleted file mode 100644 index 3558344a3..000000000 --- a/server/src/test-utils/test-data/tachi/sdvx-albida-song.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "title": "ALBIDA Powerless Mix", - "artist": "無力P", - "id": 1, - "altTitles": [], - "searchTerms": [ - "albida_muryoku", - "アルビダパワーレスミックス" - ], - "data": { - "displayVersion": "booth" - } -} \ No newline at end of file diff --git a/server/src/test-utils/test-data/tachi/sdvx-dryscore.json b/server/src/test-utils/test-data/tachi/sdvx-dryscore.json deleted file mode 100644 index 5b331ec0d..000000000 --- a/server/src/test-utils/test-data/tachi/sdvx-dryscore.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "service": "e-amusement", - "game": "sdvx", - "scoreData": { - "score": 95000000, - "lamp": "EXCESSIVE CLEAR", - "percent": 95, - "grade": "AA+", - "esd": null, - "judgements": {}, - "hitMeta": {} - }, - "scoreMeta": {}, - "timeAchieved": null, - "comment": null, - "importType": "file/batch-manual" -} \ No newline at end of file From 84432430db923b826843b39dd78e91aed089eeb6 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Tue, 21 Dec 2021 07:33:09 +0000 Subject: [PATCH 2/2] Truly tear out the rest of ktRating for iidx. --- .../calculated-data/calculated-data.ts | 8 +- .../framework/calculated-data/stats.test.ts | 124 +++++++++--------- .../framework/calculated-data/stats.ts | 2 +- .../sessions/calculated-data.test.ts | 12 +- .../framework/sessions/calculated-data.ts | 2 - .../framework/user-game-stats/rating.test.ts | 12 +- .../framework/user-game-stats/rating.ts | 2 - .../user-game-stats/update-ugs.test.ts | 17 ++- .../v1/games/_game/_playtype/router.test.ts | 2 - .../games/_game/_playtype/pbs/router.test.ts | 2 +- .../_game/_playtype/scores/router.test.ts | 2 +- .../api/v1/users/_userID/router.test.ts | 4 +- server/src/test-utils/mock-db/scores.json | 1 - 13 files changed, 86 insertions(+), 104 deletions(-) diff --git a/server/src/lib/score-import/framework/calculated-data/calculated-data.ts b/server/src/lib/score-import/framework/calculated-data/calculated-data.ts index 3e86cb76d..9a2c14240 100644 --- a/server/src/lib/score-import/framework/calculated-data/calculated-data.ts +++ b/server/src/lib/score-import/framework/calculated-data/calculated-data.ts @@ -216,7 +216,7 @@ async function CalculateDataMuseca( logger: KtLogger ): Promise> { return { - ktRating: await CalculateKTRating(dryScore, "museca", "Single", chart, logger), + ktRating: CalculateKTRating(dryScore, "museca", "Single", chart, logger), }; } @@ -249,14 +249,14 @@ function CalculateDataGitadora( }; } -async function CalculateDataDDR( +function CalculateDataDDR( dryScore: DryScore, chart: ChartDocument, logger: KtLogger -): Promise> { +): CalculatedData<"ddr:SP" | "ddr:DP"> { return { MFCP: CalculateMFCP(dryScore, chart, logger), - ktRating: await CalculateKTRating(dryScore, "ddr", chart.playtype, chart, logger), + ktRating: CalculateKTRating(dryScore, "ddr", chart.playtype, chart, logger), }; } diff --git a/server/src/lib/score-import/framework/calculated-data/stats.test.ts b/server/src/lib/score-import/framework/calculated-data/stats.test.ts index 0b6ba2888..232880cef 100644 --- a/server/src/lib/score-import/framework/calculated-data/stats.test.ts +++ b/server/src/lib/score-import/framework/calculated-data/stats.test.ts @@ -379,81 +379,81 @@ t.test("#CalculateVF6", (t) => { t.end(); }); -t.test("#CalculateRating", (t) => { - t.test("Should call the success calculator if percent > pivotPercent", async (t) => { - const r = await CalculateKTRating( - deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 80 } }), - "iidx", - "SP", - Testing511SPA, - logger - ); +t.skip("#CalculateKTRating", (t) => { + // t.test("Should call the success calculator if percent > pivotPercent", async (t) => { + // const r = await CalculateKTRating( + // deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 80 } }), + // "iidx", + // "SP", + // Testing511SPA, + // logger + // ); - t.ok(r > 10, "Should return rating greater than the levelNum of the chart."); + // t.ok(r > 10, "Should return rating greater than the levelNum of the chart."); - t.end(); - }); + // t.end(); + // }); - t.test("Should call the fail calculator if percent > pivotPercent", async (t) => { - const r = await CalculateKTRating( - TestingIIDXSPDryScore, - "iidx", - "SP", - Testing511SPA, - logger - ); + // t.test("Should call the fail calculator if percent > pivotPercent", async (t) => { + // const r = await CalculateKTRating( + // TestingIIDXSPDryScore, + // "iidx", + // "SP", + // Testing511SPA, + // logger + // ); - t.ok(r < 10, "Should return rating less than the levelNum of the chart."); + // t.ok(r < 10, "Should return rating less than the levelNum of the chart."); - t.end(); - }); + // t.end(); + // }); - t.test("Should call levelNum if percent === pivotPercent", async (t) => { - const r = await CalculateKTRating( - deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 77.7777 } }), - "iidx", - "SP", - Testing511SPA, - logger - ); + // t.test("Should call levelNum if percent === pivotPercent", async (t) => { + // const r = await CalculateKTRating( + // deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 77.7777 } }), + // "iidx", + // "SP", + // Testing511SPA, + // logger + // ); - t.equal( - // hack for approximate tests - parseFloat(r.toFixed(2)), - 10, - "Should return rating exactly that of the levelNum of the chart." - ); + // t.equal( + // // hack for approximate tests + // parseFloat(r.toFixed(2)), + // 10, + // "Should return rating exactly that of the levelNum of the chart." + // ); - t.end(); - }); + // t.end(); + // }); - t.test( - "Should trigger safety if completely invalid percent somehow gets through", - async (t) => { - let r = await CalculateKTRating( - deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 1000000000 } }), - "iidx", - "SP", - Testing511SPA, - logger - ); + // t.test( + // "Should trigger safety if completely invalid percent somehow gets through", + // async (t) => { + // let r = await CalculateKTRating( + // deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 1000000000 } }), + // "iidx", + // "SP", + // Testing511SPA, + // logger + // ); - t.equal(r, 0, "Should safely return 0 and log a warning."); + // t.equal(r, 0, "Should safely return 0 and log a warning."); - r = await CalculateKTRating( - // not high enough to be non-finite but high enough to be > 1000 - deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 200 } }), - "iidx", - "SP", - Testing511SPA, - logger - ); + // r = await CalculateKTRating( + // // not high enough to be non-finite but high enough to be > 1000 + // deepmerge(TestingIIDXSPDryScore, { scoreData: { percent: 200 } }), + // "iidx", + // "SP", + // Testing511SPA, + // logger + // ); - t.equal(r, 0, "Should safely return 0 and log a warning."); + // t.equal(r, 0, "Should safely return 0 and log a warning."); - t.end(); - } - ); + // t.end(); + // } + // ); t.end(); }); diff --git a/server/src/lib/score-import/framework/calculated-data/stats.ts b/server/src/lib/score-import/framework/calculated-data/stats.ts index 8f6c9e621..01709bba0 100644 --- a/server/src/lib/score-import/framework/calculated-data/stats.ts +++ b/server/src/lib/score-import/framework/calculated-data/stats.ts @@ -306,7 +306,7 @@ const ratingParameters = { export function CalculateKTRating( dryScore: DryScore, - game: "iidx" | "ddr" | "museca", + game: "ddr" | "museca", playtype: Playtypes[Game], chart: ChartDocument, logger: KtLogger diff --git a/server/src/lib/score-import/framework/sessions/calculated-data.test.ts b/server/src/lib/score-import/framework/sessions/calculated-data.test.ts index 9d7b6f3fa..dfd9e4224 100644 --- a/server/src/lib/score-import/framework/sessions/calculated-data.test.ts +++ b/server/src/lib/score-import/framework/sessions/calculated-data.test.ts @@ -4,7 +4,7 @@ import { CreateSessionCalcData } from "./calculated-data"; function ratingwrap(ratings: [number, number][]) { return ratings.map((e) => ({ calculatedData: { - ktRating: e[0], + BPI: e[0], ktLampRating: e[1], }, })); @@ -23,13 +23,13 @@ t.test("#CreateSessionCalcData", (t) => { t.test("Should return null if less than 10 scores", (t) => { const res = CreateSessionCalcData("iidx", "SP", ratingwrap([[1, 2]])); - t.strictSame(res, { BPI: null, ktRating: null, ktLampRating: null }); + t.strictSame(res, { BPI: null, ktLampRating: null }); t.end(); }); t.test("Should calculate session performance", (t) => { - const { BPI, ktRating, ktLampRating } = CreateSessionCalcData( + const { BPI, ktLampRating } = CreateSessionCalcData( "iidx", "SP", ratingwrap([ @@ -55,13 +55,11 @@ t.test("#CreateSessionCalcData", (t) => { ); t.equal( - ktRating, + BPI, avgbest10([1, 2, 3, 4, 6, 1, 1, 2, 3, 4, 6, 1]), - "Should correctly calculate score performance" + "Should correctly calculate BPI performance" ); - t.equal(BPI, null); - t.end(); }); diff --git a/server/src/lib/score-import/framework/sessions/calculated-data.ts b/server/src/lib/score-import/framework/sessions/calculated-data.ts index 0868984a3..61317b393 100644 --- a/server/src/lib/score-import/framework/sessions/calculated-data.ts +++ b/server/src/lib/score-import/framework/sessions/calculated-data.ts @@ -45,12 +45,10 @@ const CalculatedDataFunctions: CalculatedDataFunctions = { iidx: { SP: (scd) => ({ BPI: AvgBest10Map(scd, "BPI"), - ktRating: AvgBest10Map(scd, "ktRating"), ktLampRating: AvgBest10Map(scd, "ktLampRating"), }), DP: (scd) => ({ BPI: AvgBest10Map(scd, "BPI"), - ktRating: AvgBest10Map(scd, "ktRating"), ktLampRating: AvgBest10Map(scd, "ktLampRating"), }), }, diff --git a/server/src/lib/score-import/framework/user-game-stats/rating.test.ts b/server/src/lib/score-import/framework/user-game-stats/rating.test.ts index 29dee6cee..7de6183db 100644 --- a/server/src/lib/score-import/framework/user-game-stats/rating.test.ts +++ b/server/src/lib/score-import/framework/user-game-stats/rating.test.ts @@ -11,19 +11,11 @@ t.test("#CalculateRatings", (t) => { t.test("Should return BPI for IIDX", async (t) => { const res = await CalculateRatings("iidx", "SP", 1, logger); - t.strictSame( - res, - { BPI: 0, ktRating: 0, ktLampRating: 0 }, - "Should return BPI as a custom key." - ); + t.strictSame(res, { BPI: 0, ktLampRating: 0 }, "Should return BPI as a custom key."); const resDP = await CalculateRatings("iidx", "DP", 1, logger); - t.strictSame( - resDP, - { BPI: 0, ktRating: 0, ktLampRating: 0 }, - "Should return BPI as a custom key." - ); + t.strictSame(resDP, { BPI: 0, ktLampRating: 0 }, "Should return BPI as a custom key."); t.end(); }); diff --git a/server/src/lib/score-import/framework/user-game-stats/rating.ts b/server/src/lib/score-import/framework/user-game-stats/rating.ts index 4607c8de2..9c758062d 100644 --- a/server/src/lib/score-import/framework/user-game-stats/rating.ts +++ b/server/src/lib/score-import/framework/user-game-stats/rating.ts @@ -72,12 +72,10 @@ const RatingFunctions: RatingFunctions = { iidx: { SP: async (g, p, u) => ({ BPI: await LazyMeanN("BPI", 20)(g, p, u), - ktRating: await LazyMeanN("ktRating", 20)(g, p, u), ktLampRating: await LazyMeanN("ktLampRating", 20)(g, p, u), }), DP: async (g, p, u) => ({ BPI: await LazyMeanN("BPI", 20)(g, p, u), - ktRating: await LazyMeanN("ktRating", 20)(g, p, u), ktLampRating: await LazyMeanN("ktLampRating", 20)(g, p, u), }), }, diff --git a/server/src/lib/score-import/framework/user-game-stats/update-ugs.test.ts b/server/src/lib/score-import/framework/user-game-stats/update-ugs.test.ts index e2ea8469d..07cd3f271 100644 --- a/server/src/lib/score-import/framework/user-game-stats/update-ugs.test.ts +++ b/server/src/lib/score-import/framework/user-game-stats/update-ugs.test.ts @@ -31,7 +31,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: 0, ktLampRating: 0 }, + ratings: { ktLampRating: 0 }, classes: {}, }, "Should insert an appropriate game-stats object" @@ -57,7 +57,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: 0, ktLampRating: 0 }, + ratings: { ktLampRating: 0 }, classes: {}, }); @@ -69,8 +69,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { deepmerge(TestingIIDXSPScorePB, { chartID: crypto.randomBytes(20).toString("hex"), calculatedData: { - ktRating: e, - ktLampRating: 0, + ktLampRating: e, }, }) ) @@ -88,7 +87,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: ratings.reduce((a, r) => a + r, 0) / 20, ktLampRating: 0 }, + ratings: { ktLampRating: ratings.reduce((a, r) => a + r, 0) / 20 }, classes: {}, }, "Should update the game-stats object" @@ -104,7 +103,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: 0, ktLampRating: 0 }, + ratings: { ktLampRating: 0 }, classes: {}, }); @@ -139,7 +138,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: 0, ktLampRating: 0 }, + ratings: { ktLampRating: 0 }, classes: { dan: 18, }, @@ -157,7 +156,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: 0, ktLampRating: 0 }, + ratings: { ktLampRating: 0 }, classes: { dan: 17, }, @@ -193,7 +192,7 @@ t.test("#UpdateUsersGamePlaytypeStats", (t) => { game: "iidx", playtype: "SP", userID: 1, - ratings: { ktRating: 0, ktLampRating: 0 }, + ratings: { ktLampRating: 0 }, classes: { dan: 18, }, diff --git a/server/src/server/router/api/v1/games/_game/_playtype/router.test.ts b/server/src/server/router/api/v1/games/_game/_playtype/router.test.ts index 3aca598f7..c924361ff 100644 --- a/server/src/server/router/api/v1/games/_game/_playtype/router.test.ts +++ b/server/src/server/router/api/v1/games/_game/_playtype/router.test.ts @@ -74,7 +74,6 @@ t.test("GET /api/v1/games/:game/:playtype/leaderboard", (t) => { playtype: "SP", ratings: { BPI: 100, - ktRating: 50, }, }, { @@ -83,7 +82,6 @@ t.test("GET /api/v1/games/:game/:playtype/leaderboard", (t) => { playtype: "SP", ratings: { BPI: 50, - ktRating: 100, }, }, ] as UserGameStats[]); diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts index 5b7d1aea9..753c4ee69 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/pbs/router.test.ts @@ -100,7 +100,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/pbs", (t) => { chartID: charts[i].chartID, songID: charts[i].songID, calculatedData: { - ktRating: i, + ktLampRating: i, }, } as PBScoreDocument); } diff --git a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/scores/router.test.ts b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/scores/router.test.ts index 573f44b9b..86abe79bd 100644 --- a/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/scores/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/scores/router.test.ts @@ -99,7 +99,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/scores", (t) => { chartID: charts[i].chartID, songID: charts[i].songID, calculatedData: { - ktRating: i, + ktLampRating: i, }, } as ScoreDocument); } diff --git a/server/src/server/router/api/v1/users/_userID/router.test.ts b/server/src/server/router/api/v1/users/_userID/router.test.ts index 8147f15de..4a1bf3ea2 100644 --- a/server/src/server/router/api/v1/users/_userID/router.test.ts +++ b/server/src/server/router/api/v1/users/_userID/router.test.ts @@ -319,7 +319,7 @@ t.test("GET /api/v1/users/:userID/game-stats", (t) => { playtype: "SP", classes: {}, ratings: { - ktRating: 12, + ktLampRating: 12, }, }, { @@ -328,7 +328,7 @@ t.test("GET /api/v1/users/:userID/game-stats", (t) => { playtype: "DP", classes: {}, ratings: { - ktRating: 11, + ktLampRating: 11, }, }, { diff --git a/server/src/test-utils/mock-db/scores.json b/server/src/test-utils/mock-db/scores.json index defc169b9..b614a4ddb 100644 --- a/server/src/test-utils/mock-db/scores.json +++ b/server/src/test-utils/mock-db/scores.json @@ -21,7 +21,6 @@ }, "scoreMeta": {}, "calculatedData": { - "ktRating": 0.1, "ktLampRating": 5 }, "timeAchieved": null,