mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-07 06:18:03 +03:00
LR2Hook sends invalid BP if the user ends up exiting the song early. We need to handle this, and not accept it.
32 lines
657 B
TypeScript
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;
|