From e7c93f76201eba7510be426d21635dd078fe2c56 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 12 Jun 2021 19:01:49 +0100 Subject: [PATCH] reduced the amount of function parameters --- backend/dao/user.js | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/backend/dao/user.js b/backend/dao/user.js index 075cea3d0..1f4592052 100644 --- a/backend/dao/user.js +++ b/backend/dao/user.js @@ -103,19 +103,23 @@ class UsersDAO { static async checkIfPb( uid, - mode, - mode2, - acc, - consistency, - difficulty, - language, - punctuation, - raw, - wpm + result ) { const user = await mongoDB().collection("users").findOne({ uid }); if (!user) throw new MonkeyError(404, "User not found"); + const { + mode, + mode2, + acc, + consistency, + difficulty, + language, + punctuation, + raw, + wpm + } = result; + let pb = checkAndUpdatePb( user.personalBests, mode, @@ -141,16 +145,7 @@ class UsersDAO { static async checkIfTagPb( uid, - tags, - mode, - mode2, - acc, - consistency, - difficulty, - language, - punctuation, - raw, - wpm + result ) { const user = await mongoDB().collection("users").findOne({ uid }); if (!user) throw new MonkeyError(404, "User not found"); @@ -159,6 +154,18 @@ class UsersDAO { return []; } + const { + mode, + mode2, + acc, + consistency, + difficulty, + language, + punctuation, + raw, + wpm + } = result; + let ret = []; tags.forEach(async (tag) => {