diff --git a/server/package.json b/server/package.json index e9ab70e28..35217ff98 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.14", + "tachi-common": "0.3.15", "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 e85fa1a93..388a72a50 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.14 + tachi-common: 0.3.15 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.14 + tachi-common: 0.3.15 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.14: - resolution: {integrity: sha512-LjUItf/Lp4xHdqhH1ZBE/4Czvco2WwUs2OgHIDkYSot+Wy1F/K2xycgJp6jLkXdJeeJWVO4hSIUQakzeqdhS1A==} + /tachi-common/0.3.15: + resolution: {integrity: sha512-ZxdS+vIq9sFgpHxIn0VkaMUFcWXWsr+eHkn2HISq10Cudjv8uGzREGFSFN64e8YOKyPNYMMVi6mSoVyvY08ang==} dependencies: monk: 7.3.4 transitivePeerDependencies: diff --git a/server/scripts/bpi-poyashi-data/update-bpi-poyashi.ts b/server/scripts/bpi-poyashi-data/update-bpi-poyashi.ts index e1e6dfb84..a380dcc42 100644 --- a/server/scripts/bpi-poyashi-data/update-bpi-poyashi.ts +++ b/server/scripts/bpi-poyashi-data/update-bpi-poyashi.ts @@ -8,7 +8,7 @@ import path from "path"; import { ChartDocument, Difficulties, IIDXBPIData } from "tachi-common"; import { FindChartWithPTDFVersion } from "utils/queries/charts"; import { FindSongOnTitle } from "utils/queries/songs"; -import { RecalcAllScores } from "../__KT_DATABASE_MIGRATION/state-sync/recalc-all-scores"; +import { RecalcAllScores } from "../state-sync/recalc-all-scores"; const program = new Command(); diff --git a/server/scripts/single-use/recalc-chunithm-scores.ts b/server/scripts/single-use/recalc-chunithm-scores.ts new file mode 100644 index 000000000..84592f80d --- /dev/null +++ b/server/scripts/single-use/recalc-chunithm-scores.ts @@ -0,0 +1,49 @@ +import db from "external/mongo/db"; +import CreateLogCtx from "lib/logger/logger"; +import { GetGradeFromPercent } from "lib/score-import/framework/common/score-utils"; +import UpdateScore from "lib/score-mutation/update-score"; +import { ChartDocument, GetGamePTConfig } from "tachi-common"; + +const logger = CreateLogCtx(__filename); + +if (require.main === module) { + let i = 0; + db.scores + .find({ game: "chunithm", "scoreData.grade": "SS" }) + // @ts-expect-error dumb + .each(async (oldScore, { pause, resume }) => { + pause(); + + const chart = (await db.charts.chunithm.findOne({ + chartID: oldScore.chartID, + })) as ChartDocument<"chunithm:Single">; + + if (!chart) { + logger.severe(`Chart ${oldScore.chartID} has no chart?`); + return resume(); + } + + const newScore = JSON.parse(JSON.stringify(oldScore)); + + newScore.scoreData.grade = GetGradeFromPercent( + "chunithm", + oldScore.playtype, + oldScore.scoreData.percent + ); + + newScore.scoreData.gradeIndex = GetGamePTConfig( + "chunithm", + oldScore.playtype + ).grades.indexOf(newScore.scoreData.grade); + + await UpdateScore(oldScore, newScore); + + i++; + + resume(); + }) + .then(() => { + logger.info(`Fixed ${i} bad scores.`); + process.exit(0); + }); +} diff --git a/server/scripts/__KT_DATABASE_MIGRATION/state-sync/create-game-profiles.ts b/server/scripts/state-sync/create-game-profiles.ts similarity index 100% rename from server/scripts/__KT_DATABASE_MIGRATION/state-sync/create-game-profiles.ts rename to server/scripts/state-sync/create-game-profiles.ts diff --git a/server/scripts/__KT_DATABASE_MIGRATION/state-sync/dedupe-score-ids.ts b/server/scripts/state-sync/dedupe-score-ids.ts similarity index 100% rename from server/scripts/__KT_DATABASE_MIGRATION/state-sync/dedupe-score-ids.ts rename to server/scripts/state-sync/dedupe-score-ids.ts diff --git a/server/scripts/__KT_DATABASE_MIGRATION/state-sync/recalc-all-scores.ts b/server/scripts/state-sync/recalc-all-scores.ts similarity index 100% rename from server/scripts/__KT_DATABASE_MIGRATION/state-sync/recalc-all-scores.ts rename to server/scripts/state-sync/recalc-all-scores.ts diff --git a/server/scripts/__KT_DATABASE_MIGRATION/state-sync/recalc-sessions.ts b/server/scripts/state-sync/recalc-sessions.ts similarity index 100% rename from server/scripts/__KT_DATABASE_MIGRATION/state-sync/recalc-sessions.ts rename to server/scripts/state-sync/recalc-sessions.ts diff --git a/server/scripts/__KT_DATABASE_MIGRATION/state-sync/sync-state.ts b/server/scripts/state-sync/sync-state.ts similarity index 100% rename from server/scripts/__KT_DATABASE_MIGRATION/state-sync/sync-state.ts rename to server/scripts/state-sync/sync-state.ts diff --git a/server/scripts/__KT_DATABASE_MIGRATION/state-sync/update-all-pbs.ts b/server/scripts/state-sync/update-all-pbs.ts similarity index 100% rename from server/scripts/__KT_DATABASE_MIGRATION/state-sync/update-all-pbs.ts rename to server/scripts/state-sync/update-all-pbs.ts