Remove "dumb" rating

This commit is contained in:
Jonny_Bro (Nikita) 2024-09-09 20:56:54 +05:00
parent 46b2c0b1bf
commit 01a5886b1f
No known key found for this signature in database
GPG key ID: 3F1ECC04147E9BD8
2 changed files with 5 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "beatrun-courses-server-express", "name": "beatrun-courses-server-express",
"version": "1.2.5", "version": "1.2.6",
"scripts": { "scripts": {
"build": "tailwindcss -i ./tailwind-files/input.css -o ./public/css/style.css", "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", "watch": "tailwindcss -i ./tailwind-files/input.css -o ./public/css/style.css --watch",

View file

@ -38,8 +38,7 @@ router.get("/", async (req, res) => {
name: "Course Name", name: "Course Name",
map: "Map Name", map: "Map Name",
elements: "Element count", elements: "Element count",
scoresmart: "Rating (Smart)", scoresmart: "Rating",
scoredumb: "Rating (Dumb)",
plays: "Plays", plays: "Plays",
}; };
let sortDropdown = ""; let sortDropdown = "";
@ -98,7 +97,6 @@ router.get("/", async (req, res) => {
dislikes: rating.dislikes, dislikes: rating.dislikes,
rates: rating.ratings, rates: rating.ratings,
scoresmart: rating.rateSmart, scoresmart: rating.rateSmart,
scoredumb: rating.rateDumb,
mapimg: codeMapImage, mapimg: codeMapImage,
mapwid: codeMapId, mapwid: codeMapId,
time: codeData.time, time: codeData.time,
@ -114,7 +112,6 @@ router.get("/", async (req, res) => {
map: "STRING", map: "STRING",
elements: "DESC", elements: "DESC",
scoresmart: "DESC", scoresmart: "DESC",
scoredumb: "DESC",
plays: "DESC", plays: "DESC",
}; };
@ -181,25 +178,22 @@ router.get("/", async (req, res) => {
* - dislikes: Number of dislikes * - dislikes: Number of dislikes
* - ratings: Total number of ratings * - ratings: Total number of ratings
* - rateSmart: Likes minus dislikes * - rateSmart: Likes minus dislikes
* - rateDumb: Likes divided by total ratings
*/ */
function getCourseRating(data) { function getCourseRating(data) {
const ratings = Object.keys(data).length; 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, let likes = 0,
dislikes = 0, dislikes = 0,
rateSmart = 0, rateSmart = 0;
rateDumb = 0;
for (const r in data) if (data[r]) likes += 1; for (const r in data) if (data[r]) likes += 1;
dislikes = ratings - likes; dislikes = ratings - likes;
rateSmart = ratings + likes - dislikes; 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, "{likesCount}": course.likes,
"{dislikesCount}": course.dislikes, "{dislikesCount}": course.dislikes,
"{ratesmart}": course.scoresmart, "{ratesmart}": course.scoresmart,
"{ratedumb}": course.scoredumb,
"{mapImage}": course.mapimg, "{mapImage}": course.mapimg,
"{mapID}": course.mapwid, "{mapID}": course.mapwid,
"{elementsCount}": course.elements === 1 ? "1 element" : `${course.elements} elements`, "{elementsCount}": course.elements === 1 ? "1 element" : `${course.elements} elements`,