Skip to content

Commit

Permalink
oopsies
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Mar 31, 2024
1 parent bdf2fde commit fbd6e45
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions api/db/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit fbd6e45

Please sign in to comment.