From fbd6e45130d3f8c3f8e843d9a9036632473c865f Mon Sep 17 00:00:00 2001 From: Ianyourgod Date: Sun, 31 Mar 2024 14:36:09 -0500 Subject: [PATCH] oopsies --- api/db/UserManager.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/api/db/UserManager.js b/api/db/UserManager.js index ede75f5..5c91197 100644 --- a/api/db/UserManager.js +++ b/api/db/UserManager.js @@ -769,7 +769,8 @@ class UserManager { async hasLovedProject(id, userId) { const result = await this.projectStats.findOne({ projectId: id, - userId: userId + userId: userId, + type: "love" }); return result ? true : false @@ -785,18 +786,20 @@ class UserManager { if (love) { await this.projectStats.insertOne({ projectId: id, - userId: userId + userId: userId, + type: "love" }); return; } await this.projectStats.deleteOne({ projectId: id, - userId: userId + userId: userId, + type: "love" }); } async getProjectLoves(id) { - const result = await this.projectStats.find({projectId: id}).toArray(); + const result = await this.projectStats.find({projectId: id, type: "love"}).toArray(); return result.length; } @@ -810,7 +813,8 @@ class UserManager { async hasVotedProject(id, userId) { const result = await this.projectStats.findOne({ projectId: id, - userId: userId + userId: userId, + type: "vote" }); return result ? true : false; @@ -826,18 +830,20 @@ class UserManager { if (vote) { await this.projectStats.insertOne({ projectId: id, - userId: userId + userId: userId, + type: "vote" }); return; } await this.projectStats.deleteOne({ projectId: id, - userId: userId + userId: userId, + type: "vote" }); } async getProjectVotes(id) { - const result = await this.projectStats.find({projectId: id}).toArray(); + const result = await this.projectStats.find({projectId: id, type: "vote"}).toArray(); return result.length; }