From 2b097eaeff89435126c369d1c37cdc92fdfacbce Mon Sep 17 00:00:00 2001 From: robflop Date: Tue, 18 Jun 2019 16:14:52 +0200 Subject: [PATCH] Fix more of me fucking up the statistics cache --- src/server.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server.js b/src/server.js index c936ead6..310e70c5 100644 --- a/src/server.js +++ b/src/server.js @@ -1022,10 +1022,17 @@ schedule('0 0 * * 1', () => { }); }); // Reset weekly counter at the start of each week -schedule('0 0 * * *', () => { +schedule('1 0 * * *', () => { daily = 0; ++fetchedDaysAmount; average = Math.round(monthly / fetchedDaysAmount); - statistics[dateFns.format(new Date(), 'YYYY-MM-DD')] = 0; + + const latestID = statistics[statistics.length - 1].id; + + statistics.push({ + id: latestID + 1, + date: dateFns.format(new Date(), 'YYYY-MM-DD'), + count: 0, + }); Logger.info('Daily counter reset & fetched days amount incremented.'); return emitUpdate({ @@ -1035,4 +1042,4 @@ schedule('0 0 * * *', () => { summary: { alltime: counter, daily, weekly, monthly, yearly, average } }, }); -}); // Reset daily counter and update local statistics map at each midnight \ No newline at end of file +}); // Reset daily counter and update local statistics map at 1 minute past midnight \ No newline at end of file