mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-05 21:38:06 +03:00
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.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import UGPTAddPreferredRanking from "./migrations/add-preferredRanking-to-ugpt";
|
||||
import UGPTRivalsMigration from "./migrations/add-rivals-to-ugpt";
|
||||
import NullLR2HookFailedBPs from "./migrations/null-lr2hook-failed-bps";
|
||||
import RecalcBrokenIIDXNotecounts from "./migrations/recalc-broken-iidx-notecounts";
|
||||
import RemoveIIDXBeginners from "./migrations/remove-iidx-beginners";
|
||||
import RemoveMultifolderStats from "./migrations/remove-multifolder-stats";
|
||||
@@ -44,7 +45,7 @@ if (Environment.nodeEnv !== "test") {
|
||||
|
||||
// bokutachi specific migrations
|
||||
if (TachiConfig.TYPE !== "ktchi") {
|
||||
// none, currently
|
||||
REGISTERED_MIGRATIONS.push(NullLR2HookFailedBPs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user