Fix implementation bug with recalcing sessions in a site recalc.

This commit is contained in:
zkldi
2021-12-16 15:38:44 +00:00
parent 6f2e1f51f5
commit f04d594ae5
@@ -155,7 +155,11 @@ router.post("/delete-score", prValidate({ scoreID: "string" }), async (req, res)
});
/**
* Destroys a users UGPT profile and forces a site recalc.
* Destroys a users UGPT profile and forces a leaderboard recalc.
*
* @param userID - The U...
* @param game - The G...
* @param playtype - And the PT to delete.
*
* @name POST /api/v1/admin/destroy-ugpt
*/
@@ -195,6 +199,9 @@ router.post(
/**
* Destroy a chart and all of its scores (and sessions).
*
* @param chartID - The chartID to delete.
* @param game - The game this chart is for. Necessary for doing lookups.
*
* @name POST /api/v1/admin/destroy-chart
*/
router.post(
@@ -271,7 +278,18 @@ router.post(
router.post("/recalc", async (req, res) => {
const filter = req.body ?? {};
await RecalcAllScores(filter);
await RecalcSessions(filter);
const scoreIDs = (
await db.scores.find(filter, {
projection: {
scoreID: 1,
},
})
).map((e) => e.scoreID);
await RecalcSessions({
"scoreInfo.scoreID": { $in: scoreIDs },
});
return res.status(200).json({
success: true,