Files
zkldi_Tachi/server/src/lib/migration/migrations/null-lr2hook-failed-bps.ts
T
zkldi 7eaa8bc06b fix(lr2hook): reject BP if user failed
LR2Hook sends invalid BP if the user ends up exiting the song early.
We need to handle this, and not accept it.
2022-10-27 19:46:33 +01:00

32 lines
657 B
TypeScript

import db from "external/mongo/db";
import { UpdateAllPBs } from "utils/calculations/recalc-scores";
import type { Migration } from "utils/types";
const migration: Migration = {
id: "null-lr2hook-failed-bps",
up: async () => {
await db.scores.update(
{
importType: "ir/lr2hook",
"scoreMeta.gauge": "HARD",
lamp: { $in: ["FAILED", "NO PLAY"] },
},
{
$set: {
"scoreData.hitMeta.bp": null,
},
},
{
multi: true,
}
);
await UpdateAllPBs(undefined, { game: "bms" });
},
down: () => {
throw new Error(`Unable to revert transaction, some scores may have been nulled.`);
},
};
export default migration;