mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-10 13:44:27 +08:00
reduced user db calls
This commit is contained in:
parent
6752b6086a
commit
16bb753601
1 changed files with 2 additions and 12 deletions
|
@ -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 },
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue