From 16bb7536011be924392d65b2864f0deb49acf9cd Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 3 Mar 2022 23:25:30 +0100 Subject: [PATCH] reduced user db calls --- backend/dao/user.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/backend/dao/user.js b/backend/dao/user.js index c494ec1d8..f29252aa4 100644 --- a/backend/dao/user.js +++ b/backend/dao/user.js @@ -166,10 +166,7 @@ class UsersDAO { ); } - static async checkIfPb(uid, result) { - const user = await db.collection("users").findOne({ uid }); - if (!user) throw new MonkeyError(404, "User not found", "check if pb"); - + static async checkIfPb(uid, user, result) { const { mode, mode2, @@ -225,10 +222,7 @@ class UsersDAO { } } - static async checkIfTagPb(uid, result) { - const user = await db.collection("users").findOne({ uid }); - if (!user) throw new MonkeyError(404, "User not found", "check if tag pb"); - + static async checkIfTagPb(uid, user, result) { if (user.tags === undefined || user.tags.length === 0) { return []; } @@ -305,10 +299,6 @@ class UsersDAO { } static async updateTypingStats(uid, restartCount, timeTyping) { - const user = await db.collection("users").findOne({ uid }); - if (!user) - throw new MonkeyError(404, "User not found", "update typing stats"); - return await db.collection("users").updateOne( { uid }, {