mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-04 04:48:15 +03:00
Move scripts into src/
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import db from "external/mongo/db";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
async function DedupeScoreIDs() {
|
||||
const dups = await db.scores.aggregate(
|
||||
[
|
||||
{
|
||||
$group: {
|
||||
_id: "$scoreID",
|
||||
dups: { $addToSet: "$_id" },
|
||||
count: { $sum: 1 },
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
count: { $gt: 1 },
|
||||
},
|
||||
},
|
||||
],
|
||||
{ allowDiskUse: true }
|
||||
);
|
||||
|
||||
logger.info(`Found ${dups.length} dups.`);
|
||||
|
||||
for (const dup of dups) {
|
||||
dup.dups.shift();
|
||||
await db.scores.remove({ _id: { $in: dup.dups } });
|
||||
}
|
||||
|
||||
logger.info(`Done.`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
DedupeScoreIDs();
|
||||
@@ -0,0 +1,5 @@
|
||||
import { RecalcAllScores } from "utils/calculations/recalc-scores";
|
||||
|
||||
if (require.main === module) {
|
||||
RecalcAllScores();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
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 { FormatUserDoc } from "utils/user";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
export async function CreateGameProfiles() {
|
||||
const users = await db.users.find({});
|
||||
|
||||
for (const user of users) {
|
||||
const gpts = await db.scores.aggregate([
|
||||
{
|
||||
$match: {
|
||||
userID: user.id,
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
game: "$game",
|
||||
playtype: "$playtype",
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
logger.info(`Found ${gpts.length} GPTs for ${FormatUserDoc(user)}`);
|
||||
|
||||
for (const gpt of gpts) {
|
||||
const { game, playtype } = gpt._id;
|
||||
logger.info(`Updating ${FormatUserDoc(user)}'s ${game} ${playtype} stats.`);
|
||||
await UpdateUsersGamePlaytypeStats(game, playtype, user.id, null, logger);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`Done.`);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
CreateGameProfiles().then(() => process.exit(0));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { RecalcSessions } from "utils/calculations/recalc-sessions";
|
||||
|
||||
if (require.main === module) {
|
||||
RecalcSessions().then(() => process.exit(0));
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { RecalcAllScores, UpdateAllPBs } from "utils/calculations/recalc-scores";
|
||||
import { RecalcSessions } from "utils/calculations/recalc-sessions";
|
||||
import { CreateGameProfiles } from "./recalc-game-profiles";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
(async () => {
|
||||
await RecalcAllScores();
|
||||
await UpdateAllPBs();
|
||||
await CreateGameProfiles();
|
||||
await RecalcSessions();
|
||||
|
||||
logger.info(`Completely done!`);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { UpdateAllPBs } from "utils/calculations/recalc-scores";
|
||||
|
||||
if (require.main === module) {
|
||||
UpdateAllPBs();
|
||||
}
|
||||
Reference in New Issue
Block a user