mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-30 02:48:01 +03:00
Make destroy-chart use DeleteMultipleScores
This commit is contained in:
@@ -9,7 +9,7 @@ import { ONE_MINUTE } from "lib/constants/time";
|
||||
import { ServerConfig, TachiConfig } from "lib/setup/config";
|
||||
import { Game, UserAuthLevels } from "tachi-common";
|
||||
import db from "external/mongo/db";
|
||||
import { DeleteScore } from "lib/score-mutation/delete-scores";
|
||||
import { DeleteMultipleScores, DeleteScore } from "lib/score-mutation/delete-scores";
|
||||
import { RecalcAllScores, UpdateAllPBs } from "utils/calculations/recalc-scores";
|
||||
import DestroyUserGamePlaytypeData from "utils/reset-state/destroy-ugpt";
|
||||
import { RecalcSessions } from "utils/calculations/recalc-sessions";
|
||||
@@ -210,58 +210,21 @@ router.post(
|
||||
async (req, res) => {
|
||||
const game: Game = req.body.game;
|
||||
const chartID: string = req.body.chartID;
|
||||
await db.charts[game].remove({
|
||||
chartID,
|
||||
});
|
||||
|
||||
const scores = await db.scores.find({
|
||||
chartID,
|
||||
});
|
||||
|
||||
const scoreIDs = scores.map((e) => e.scoreID);
|
||||
await DeleteMultipleScores(scores);
|
||||
|
||||
await db.scores.remove({
|
||||
scoreID: { $in: scoreIDs },
|
||||
await db.charts[game].remove({
|
||||
chartID,
|
||||
});
|
||||
|
||||
await db["personal-bests"].remove({
|
||||
chartID,
|
||||
});
|
||||
|
||||
const sessions = await db.sessions.find({
|
||||
"scoreInfo.scoreID": { $in: scoreIDs },
|
||||
});
|
||||
|
||||
for (const session of sessions) {
|
||||
await db.sessions.update(
|
||||
{
|
||||
sessionID: session.sessionID,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
scoreInfo: session.scoreInfo.filter((e) => !scoreIDs.includes(e.scoreID)),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const imports = await db.imports.find({
|
||||
scoreIDs: { $in: scoreIDs },
|
||||
});
|
||||
|
||||
for (const imp of imports) {
|
||||
await db.imports.update(
|
||||
{
|
||||
importID: imp.importID,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
scoreIDs: imp.scoreIDs.filter((e) => !scoreIDs.includes(e)),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
description: `Obliterated chart.`,
|
||||
|
||||
Reference in New Issue
Block a user