mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-08 22:59:52 +03:00
fix: this probably solves the kai screaming (#1051)
* fix: this probably solves the kai screaming * clean up, mock out for tests
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
"rules": {
|
||||
// broken
|
||||
"lines-around-comment": "off",
|
||||
|
||||
// no idea why this is on
|
||||
"no-param-reassign": "off",
|
||||
// TENPORARILY OFF AS THEY'RE BROKEN.
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-return": "off",
|
||||
|
||||
@@ -129,20 +129,21 @@ export default async function ScoreImportMain<D, C>(
|
||||
job
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`An error was thrown from ImportAllIterableData, which has resulted in a potential partial-score-import. Undoing scores inserted from this import.`,
|
||||
{ err }
|
||||
);
|
||||
|
||||
// Remove all scores from the database for this user which were imported after our timer started.
|
||||
const r = await db.scores.remove({
|
||||
userID: user.id,
|
||||
timeAdded: { $gte: startOfImportingScores },
|
||||
});
|
||||
|
||||
logger.error(
|
||||
`Removed ${r.deletedCount} scores from the database to undo partial-import.`
|
||||
);
|
||||
if (r.deletedCount !== 0) {
|
||||
logger.error(
|
||||
`An error was thrown from ImportAllIterableData, which has resulted in a potential partial-score-import. Undoing scores inserted from this import.`,
|
||||
{ err }
|
||||
);
|
||||
logger.error(
|
||||
`Removed ${r.deletedCount} scores from the database to undo partial-import.`
|
||||
);
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ const fakeAuth = {
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const NO_REAUTH = () => Promise.resolve("");
|
||||
|
||||
t.test("#ParseKaiIIDX", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -32,7 +34,7 @@ t.test("#ParseKaiIIDX", (t) => {
|
||||
},
|
||||
});
|
||||
|
||||
const res = await ParseKaiIIDX("FLO", fakeAuth, logger, mockFloAPI);
|
||||
const res = await ParseKaiIIDX("FLO", fakeAuth, logger, mockFloAPI, NO_REAUTH);
|
||||
|
||||
t.equal(res.game, "iidx");
|
||||
t.strictSame(res.context, { service: "FLO" });
|
||||
@@ -64,7 +66,7 @@ t.test("#ParseKaiIIDX", (t) => {
|
||||
},
|
||||
});
|
||||
|
||||
const res = await ParseKaiIIDX("EAG", fakeAuth, logger, mockEagAPI);
|
||||
const res = await ParseKaiIIDX("EAG", fakeAuth, logger, mockEagAPI, NO_REAUTH);
|
||||
|
||||
t.equal(res.game, "iidx");
|
||||
t.strictSame(res.context, { service: "EAG" });
|
||||
|
||||
@@ -12,11 +12,17 @@ export async function ParseKaiIIDX(
|
||||
service: "EAG" | "FLO",
|
||||
authDoc: KaiAuthDocument,
|
||||
logger: KtLogger,
|
||||
fetch = nodeFetch
|
||||
fetch = nodeFetch,
|
||||
reauthFn: (() => Promise<string>) | null = null
|
||||
): Promise<ParserFunctionReturns<unknown, KaiContext>> {
|
||||
const baseUrl = KaiTypeToBaseURL(service);
|
||||
|
||||
const reauthFn = CreateKaiReauthFunction(service, authDoc, logger, fetch);
|
||||
if (!reauthFn) {
|
||||
reauthFn = CreateKaiReauthFunction(service, authDoc, logger, fetch);
|
||||
}
|
||||
|
||||
// auth *before* starting import to avoid a partial-import
|
||||
authDoc.token = await reauthFn();
|
||||
|
||||
return {
|
||||
iterable: TraverseKaiAPI(
|
||||
|
||||
@@ -13,6 +13,8 @@ const fakeAuth = {
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
const NO_REAUTH = () => Promise.resolve("");
|
||||
|
||||
t.test("#ParseKaiSDVX", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -32,7 +34,7 @@ t.test("#ParseKaiSDVX", (t) => {
|
||||
},
|
||||
});
|
||||
|
||||
const res = await ParseKaiSDVX("FLO", fakeAuth, logger, mockFloAPI);
|
||||
const res = await ParseKaiSDVX("FLO", fakeAuth, logger, mockFloAPI, NO_REAUTH);
|
||||
|
||||
t.equal(res.game, "sdvx");
|
||||
t.strictSame(res.context, { service: "FLO" });
|
||||
@@ -64,7 +66,7 @@ t.test("#ParseKaiSDVX", (t) => {
|
||||
},
|
||||
});
|
||||
|
||||
const res = await ParseKaiSDVX("EAG", fakeAuth, logger, mockEagAPI);
|
||||
const res = await ParseKaiSDVX("EAG", fakeAuth, logger, mockEagAPI, NO_REAUTH);
|
||||
|
||||
t.equal(res.game, "sdvx");
|
||||
t.strictSame(res.context, { service: "EAG" });
|
||||
|
||||
@@ -12,11 +12,17 @@ export async function ParseKaiSDVX(
|
||||
service: "EAG" | "FLO" | "MIN",
|
||||
authDoc: KaiAuthDocument,
|
||||
logger: KtLogger,
|
||||
fetch = nodeFetch
|
||||
fetch = nodeFetch,
|
||||
reauthFn: (() => Promise<string>) | null = null
|
||||
): Promise<ParserFunctionReturns<unknown, KaiContext>> {
|
||||
const baseUrl = KaiTypeToBaseURL(service);
|
||||
|
||||
const reauthFn = CreateKaiReauthFunction(service, authDoc, logger, fetch);
|
||||
if (!reauthFn) {
|
||||
reauthFn = CreateKaiReauthFunction(service, authDoc, logger, fetch);
|
||||
}
|
||||
|
||||
// auth *before* starting import to avoid a partial-import
|
||||
authDoc.token = await reauthFn();
|
||||
|
||||
return {
|
||||
iterable: TraverseKaiAPI(
|
||||
|
||||
Reference in New Issue
Block a user