Skip to content

Commit

Permalink
should be all working now
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Mar 31, 2024
1 parent 6a8ffb5 commit 55dcb54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/db/UMTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ async function tests() {

let deleteProject = await manager.deleteProject(getProjects[0].id);
let getDeletedProject = await manager.getProjectData(getProjects[0].id);
if (getDeletedProject !== null) {
if (getDeletedProject) {
console.log(getDeletedProject);
console.log("[ FAIL ]".red, "Failed to delete project");
return false;
}
Expand Down
10 changes: 9 additions & 1 deletion api/db/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ class UserManager {
notes: notes,
remix: remix,
featured: false,
views: 0,
date: Date.now(),
lastUpdate: Date.now(),
rating: rating
Expand Down Expand Up @@ -716,6 +717,8 @@ class UserManager {
* @async
*/
async getProjectData(id) {
if (!await this.projectExists(id)) return false;

const tempresult = await this.projects.findOne({id: id})

// add the views, loves, and votes
Expand Down Expand Up @@ -755,6 +758,7 @@ class UserManager {
}

this.views.push({id: id, ip: ip});
await this.projects.updateOne({id: id}, {$inc: {views: 1}});
}

async getProjectViews(id) {
Expand Down Expand Up @@ -885,6 +889,10 @@ class UserManager {
*/
async deleteProject(id) {
await this.projects.deleteOne({id: id});

// remove the loves and votes
await this.projectStats.deleteMany({projectId: id});

fs.rmSync(path.join(__dirname, `./projects/files/project_${id}.pmp`));
fs.rmSync(path.join(__dirname, `./projects/images/project_${id}.png`));
}
Expand Down Expand Up @@ -1000,7 +1008,7 @@ class UserManager {
async projectExists(id) {
const result = await this.projects.findOne({id: id});

return result !== undefined;
return result ? true : false;
}

/**
Expand Down

0 comments on commit 55dcb54

Please sign in to comment.