fix: broken batch manual classhandler logic (#1314)

Co-authored-by: zkldi <20380519+zkldi@users.noreply.github.com>
This commit is contained in:
zk
2025-07-06 13:04:33 +01:00
committed by GitHub
co-authored by zkldi
parent 05b8620c29
commit e445beea7e
4 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -48,7 +48,7 @@
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
// we abuse this one for faking data, but we really shouldn't.
"@typescript-eslint/consistent-type-assertions": "warn"
"@typescript-eslint/consistent-type-assertions": "off"
}
}
]
@@ -6,9 +6,14 @@ import type { Classes, GPTString } from "tachi-common";
// Note: This is tested by batch-manuals parser.test.ts.
export function CreateBatchManualClassProvider(
outerGptString: GPTString,
classes: Partial<Record<Classes[GPTString], string | null>>
): ClassProvider {
return (gptString, userID, ratings, logger) => {
if (outerGptString !== gptString) {
return {};
}
const gptConfig = GetGPTConfig(gptString);
const newObj: Partial<Record<Classes[GPTString], string>> = {};
@@ -2,7 +2,6 @@ import { ParseBatchManualFromObject as ParserFn } from "./parser";
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
import deepmerge from "deepmerge";
import CreateLogCtx from "lib/logger/logger";
import { IIDX_DANS } from "tachi-common";
import t from "tap";
import { EscapeStringRegexp } from "utils/misc";
import type { BatchManual } from "tachi-common";
@@ -350,6 +349,7 @@ t.test("#ParserFn", (t) => {
t.not(res.classProvider, null);
t.strictSame(res.classProvider!("iidx:SP", 1, {}, logger), { dan: "KAIDEN" });
t.strictSame(res.classProvider!("iidx:DP", 1, {}, logger), {});
t.end();
});
@@ -2,7 +2,7 @@ import { CreateBatchManualClassProvider } from "./class-handler";
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
import { TachiConfig } from "lib/setup/config";
import { p } from "prudence";
import { GetGameConfig } from "tachi-common";
import { GetGameConfig, GetGPTString } from "tachi-common";
import { PR_BATCH_MANUAL } from "tachi-common/lib/schemas";
import { IsRecord, IsValidGame, IsValidPlaytype } from "utils/misc";
import { FormatPrError } from "utils/prudence";
@@ -126,7 +126,7 @@ export function ParseBatchManualFromObject(
// if classes are provided, use those as a class handler. Otherwise, we
// don't care.
classProvider: batchManual.classes
? CreateBatchManualClassProvider(batchManual.classes)
? CreateBatchManualClassProvider(GetGPTString(game, playtype), batchManual.classes)
: null,
};
}