mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-11 16:58:25 +03:00
refactor: use a util for script exec
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import db from "external/mongo/db";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { WrapScriptPromise } from "utils/misc";
|
||||
import type { IObjectID } from "monk";
|
||||
import type { integer } from "tachi-common";
|
||||
|
||||
@@ -34,14 +35,6 @@ async function DedupeScoreIDs() {
|
||||
}
|
||||
}
|
||||
|
||||
DedupeScoreIDs()
|
||||
.then(() => {
|
||||
logger.info(`Finished deduping score IDs.`, () => {
|
||||
process.exit(0);
|
||||
});
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
logger.error(`Failed to dedupe score IDs.`, { err }, () => {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
if (require.main === module) {
|
||||
WrapScriptPromise(DedupeScoreIDs(), logger);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { RecalcAllScores } from "utils/calculations/recalc-scores";
|
||||
import { WrapScriptPromise } from "utils/misc";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
if (require.main === module) {
|
||||
RecalcAllScores()
|
||||
.then(() => {
|
||||
logger.info(`Successfully recalced all scores.`, () => {
|
||||
process.exit(0);
|
||||
});
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
logger.error(`Failed to recalc all scores.`, { err }, () => {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
WrapScriptPromise(RecalcAllScores(), logger);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import db from "external/mongo/db";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { UpdateUsersGamePlaytypeStats } from "lib/score-import/framework/user-game-stats/update-ugs";
|
||||
import { WrapScriptPromise } from "utils/misc";
|
||||
import { FormatUserDoc } from "utils/user";
|
||||
import type { Game, Playtype, ScoreDocument } from "tachi-common";
|
||||
|
||||
@@ -42,11 +43,5 @@ export async function RecalcGameProfiles() {
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
RecalcGameProfiles()
|
||||
.then(() => process.exit(0))
|
||||
.catch((err: unknown) => {
|
||||
logger.error(`Failed to recalc game profiles.`, { err }, () => {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
WrapScriptPromise(RecalcGameProfiles(), logger);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { RecalcSessions } from "utils/calculations/recalc-sessions";
|
||||
import { WrapScriptPromise } from "utils/misc";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
if (require.main === module) {
|
||||
RecalcSessions()
|
||||
.then(() => process.exit(0))
|
||||
.catch((err: unknown) => {
|
||||
logger.error(`Failed to recalc sessions.`, { err }, () => {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
WrapScriptPromise(RecalcSessions(), logger);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { UpdateAllPBs } from "utils/calculations/recalc-scores";
|
||||
import { WrapScriptPromise } from "utils/misc";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
if (require.main === module) {
|
||||
UpdateAllPBs()
|
||||
.then(() => {
|
||||
logger.info(`Successfully updated all PBs.`);
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
logger.error(`Failed to update all PBs.`, { err }, () => {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
WrapScriptPromise(UpdateAllPBs(), logger);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user