From 28bdbbb2795b8c8de07d0a1a311d8bcfe338560d Mon Sep 17 00:00:00 2001 From: zkldi Date: Wed, 28 Apr 2021 22:40:15 +0100 Subject: [PATCH] which means we no longer need autocoerce --- common/src/common-core/score-core.ts | 53 ---------------------------- 1 file changed, 53 deletions(-) delete mode 100644 common/src/common-core/score-core.ts diff --git a/common/src/common-core/score-core.ts b/common/src/common-core/score-core.ts deleted file mode 100644 index 465d20ff3..000000000 --- a/common/src/common-core/score-core.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { ScoreDocument } from ".."; -import { ICollection } from "monk"; - -export async function AutoCoerce( - collection: ICollection, - scores: ScoreDocument[] -): Promise { - let notPBsArr = []; - - for (const s of scores) { - if (!s.isLampPB) { - notPBsArr.push({ - userID: s.userID, - chartID: s.chartID, - isLampPB: true, - }); - } - } - - if (notPBsArr.length === 0) { - return scores; - } - - let lampPBsArr = await collection.find({ - $or: notPBsArr, - }); - - let lampPBs: Map = new Map(); - for (const score of lampPBsArr) { - lampPBs.set(`${score.userID}-${score.chartID}`, score); - } - - for (const score of scores) { - if (!score.isLampPB) { - let lampPB = lampPBs.get(`${score.userID}-${score.chartID}`); - - if (lampPB) { - score.scoreData.lamp = lampPB.scoreData.lamp; - score.scoreData.lampIndex = lampPB.scoreData.lampIndex; - score.calculatedData.lampRating = lampPB.calculatedData.lampRating; - - // not too happy about this, this is a sign - // of something not properly being generalised. - if (score.game === "bms") { - score.calculatedData.rating = lampPB.calculatedData.rating; - } - score.isLampPB = true; - } - } - } - - return scores; -}