mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-02 20:08:17 +03:00
Merge pull request #581 from TNG-dev:zkldi/issue-577
Add script for fixing CHUNITHM's broken grades.
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
Generated
+4
-4
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user