From 01a5886b1f15d1efc3d2d969f144527429ceb4f3 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Mon, 9 Sep 2024 20:56:54 +0500 Subject: [PATCH] Remove "dumb" rating --- package.json | 2 +- routes/index.js | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 049e675..ee83262 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "beatrun-courses-server-express", - "version": "1.2.5", + "version": "1.2.6", "scripts": { "build": "tailwindcss -i ./tailwind-files/input.css -o ./public/css/style.css", "watch": "tailwindcss -i ./tailwind-files/input.css -o ./public/css/style.css --watch", diff --git a/routes/index.js b/routes/index.js index 9fbea4d..c06873f 100644 --- a/routes/index.js +++ b/routes/index.js @@ -38,8 +38,7 @@ router.get("/", async (req, res) => { name: "Course Name", map: "Map Name", elements: "Element count", - scoresmart: "Rating (Smart)", - scoredumb: "Rating (Dumb)", + scoresmart: "Rating", plays: "Plays", }; let sortDropdown = ""; @@ -98,7 +97,6 @@ router.get("/", async (req, res) => { dislikes: rating.dislikes, rates: rating.ratings, scoresmart: rating.rateSmart, - scoredumb: rating.rateDumb, mapimg: codeMapImage, mapwid: codeMapId, time: codeData.time, @@ -114,7 +112,6 @@ router.get("/", async (req, res) => { map: "STRING", elements: "DESC", scoresmart: "DESC", - scoredumb: "DESC", plays: "DESC", }; @@ -181,25 +178,22 @@ router.get("/", async (req, res) => { * - dislikes: Number of dislikes * - ratings: Total number of ratings * - rateSmart: Likes minus dislikes - * - rateDumb: Likes divided by total ratings */ function getCourseRating(data) { const ratings = Object.keys(data).length; - if (ratings <= 0) return { likes: 0, dislikes: 0, ratings: 0, rateSmart: 0, rateDumb: 0 }; + if (ratings <= 0) return { likes: 0, dislikes: 0, ratings: 0, rateSmart: 0 }; let likes = 0, dislikes = 0, - rateSmart = 0, - rateDumb = 0; + rateSmart = 0; for (const r in data) if (data[r]) likes += 1; dislikes = ratings - likes; rateSmart = ratings + likes - dislikes; - rateDumb = likes / ratings; - return { likes: likes, dislikes: dislikes, ratings: ratings, rateSmart: rateSmart, rateDumb: rateDumb }; + return { likes: likes, dislikes: dislikes, ratings: ratings, rateSmart: rateSmart }; } /** @@ -219,7 +213,6 @@ function generateCourseCard(course) { "{likesCount}": course.likes, "{dislikesCount}": course.dislikes, "{ratesmart}": course.scoresmart, - "{ratedumb}": course.scoredumb, "{mapImage}": course.mapimg, "{mapID}": course.mapwid, "{elementsCount}": course.elements === 1 ? "1 element" : `${course.elements} elements`,