From 705a3c39da6fb9913da56a215c60c883829ec401 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 1 Sep 2019 22:36:20 -0400 Subject: [PATCH] Added days saved stat. --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ac2a9f4..93ff897 100644 --- a/index.js +++ b/index.js @@ -501,6 +501,18 @@ app.get('/api/getTotalStats', function (req, res) { }); }); +//send out a formatted time saved total +app.get('/api/getDaysSavedFormatted', function (req, res) { + db.prepare("SELECT SUM((endTime - startTime) / 60 / 60 / 24 * views) as daysSaved FROM sponsorTimes").get(function(err, row) { + if (row != null) { + //send this result + res.send({ + daysSaved: row.daysSaved.toFixed(2) + }); + } + }); +}); + app.get('/database.db', function (req, res) { res.sendFile("./databases/sponsorTimes.db", { root: __dirname }); }); @@ -704,4 +716,4 @@ function getHash(value, times=5000) { } return value; -} +} \ No newline at end of file