From 71f9ca7d70af2f0117ea126be24e07d497b03a5a Mon Sep 17 00:00:00 2001 From: Vivek W <92390419+AryanVBW@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:58:31 +0530 Subject: [PATCH 1/2] update date --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4537862..e17ac14 100644 --- a/index.js +++ b/index.js @@ -51,10 +51,10 @@ app.get("/", async (req, res) => { const noOfDaysInWeek = 7; for (let index = 0; index < noOfDaysInWeek; index++) { - const reqDate = moment("2024-12-08", "YYYY-MM-DD") + const reqDate = moment() .subtract(index, 'days') .format('DD/MM/YYYY'); - const prevDate = moment("2024-12-08", "YYYY-MM-DD") + const prevDate = moment() .subtract(index + 1, 'days') .format('DD/MM/YYYY'); From bf9422f998f0f91a8036169f2251f07e00129dda Mon Sep 17 00:00:00 2001 From: KanishkRanjan <68316017+KanishkRanjan@users.noreply.github.com> Date: Fri, 29 Nov 2024 22:48:50 +0530 Subject: [PATCH 2/2] Bug fix: fixing leaderboard streak if data not found --- index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index e17ac14..86df453 100644 --- a/index.js +++ b/index.js @@ -58,12 +58,8 @@ app.get("/", async (req, res) => { .subtract(index + 1, 'days') .format('DD/MM/YYYY'); - if (userData.solved && - userData.solved[reqDate] !== undefined && - userData.solved[prevDate] !== undefined) { - timeline[noOfDaysInWeek - index - 1] = - parseInt(userData.solved[reqDate]) > parseInt(userData.solved[prevDate]); - } + if(reqDate in userData['solved'] && prevDate in userData['solved']) + timeline[noOfDaysInWeek - index -1] = (parseInt(userData['solved'][reqDate]) > parseInt(userData['solved'][prevDate])) ; } return { @@ -103,4 +99,4 @@ const startServer = async () => { } }; -startServer(); \ No newline at end of file +startServer();