mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-30 10:58:07 +03:00
Make sure the poyashi script recalcs iidx profiles.
This commit is contained in:
@@ -3,6 +3,7 @@ import db from "external/mongo/db";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import fetch from "node-fetch";
|
||||
import { ChartDocument, Difficulties, IIDXBPIData } from "tachi-common";
|
||||
import { RecalcGameProfiles } from "utils/calculations/recalc-game-profiles";
|
||||
import { RecalcAllScores } from "utils/calculations/recalc-scores";
|
||||
import { RecalcSessions } from "utils/calculations/recalc-sessions";
|
||||
import { FindChartWithPTDFVersion } from "utils/queries/charts";
|
||||
@@ -128,6 +129,8 @@ async function UpdatePoyashiData() {
|
||||
// @optimisable -- can be filtered to just scores that were recalced.
|
||||
await RecalcSessions({ game: "iidx" });
|
||||
|
||||
await RecalcGameProfiles({ game: "iidx" });
|
||||
|
||||
logger.info(`Done.`);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
|
||||
import db from "external/mongo/db";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { CreateSessionCalcData } from "lib/score-import/framework/sessions/calculated-data";
|
||||
import { UpdateUsersGamePlaytypeStats } from "lib/score-import/framework/user-game-stats/update-ugs";
|
||||
import { FormatUserDoc } from "utils/user";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export async function RecalcGameProfiles(filter = {}) {
|
||||
const profiles = await db["game-stats"].find(filter);
|
||||
|
||||
for (const profile of profiles) {
|
||||
const user = await db.users.findOne({
|
||||
id: profile.userID,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
logger.severe(`User ${profile.userID} does not exist?`);
|
||||
throw new Error(`User ${profile.userID} does not exist.`);
|
||||
}
|
||||
|
||||
logger.verbose(
|
||||
`Recalcing ${FormatUserDoc(user)}'s ${profile.game} ${profile.playtype} stats.`
|
||||
);
|
||||
await UpdateUsersGamePlaytypeStats(
|
||||
profile.game,
|
||||
profile.playtype,
|
||||
profile.userID,
|
||||
null,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
logger.info(`Done.`);
|
||||
}
|
||||
Reference in New Issue
Block a user