From 7481b42499724985ed46189487dfb1975461c92d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 16 Apr 2020 20:14:13 -0400 Subject: [PATCH 1/7] Update README.MD --- README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.MD b/README.MD index d56f940..37d541b 100644 --- a/README.MD +++ b/README.MD @@ -8,7 +8,7 @@ This is the server backend for it This is a simple Sqlite database that will hold all the timing data. -To make sure that this project doesn't die, I have made the database publicly downloadable at https://api.sponsor.ajay.app/database.db (formerly https://sponsor.ajay.app/database.db). You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me. +To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me. Hopefully this project can be combined with projects like [this](https://github.com/Sponsoff/sponsorship_remover) and use this data to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea. From 950b8ecb55412ed4dd8af3c0fb2ba1b1cd1c0832 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 19 Apr 2020 19:18:24 -0400 Subject: [PATCH 2/7] Update getDaysSavedFormatted.js --- src/routes/getDaysSavedFormatted.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/getDaysSavedFormatted.js b/src/routes/getDaysSavedFormatted.js index 7fece0c..2f0b141 100644 --- a/src/routes/getDaysSavedFormatted.js +++ b/src/routes/getDaysSavedFormatted.js @@ -1,4 +1,4 @@ -var db = require('../databases/databases.js'); +var db = require('../databases/databases.js').db; module.exports = function getDaysSavedFormatted (req, res) { let row = db.prepare("select sum((endtime - starttime) / 60 / 60 / 24 * views) as dayssaved from sponsortimes where shadowhidden != 1").get(); @@ -9,4 +9,4 @@ module.exports = function getDaysSavedFormatted (req, res) { dayssaved: row.dayssaved.tofixed(2) }); } -} \ No newline at end of file +} From 14e21a1009993a63b70950f0cec99a175c586c41 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 19 Apr 2020 19:22:38 -0400 Subject: [PATCH 3/7] Fixed wrong database being sent --- src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index 3c7ec8a..043ce44 100644 --- a/src/app.js +++ b/src/app.js @@ -85,7 +85,7 @@ app.get('/api/getTotalStats', getTotalStats); app.get('/api/getdayssavedformatted', getDaysSavedFormatted); app.get('/database.db', function (req, res) { - res.sendfile("./databases/sponsortimes.db", { root: __dirname }); + res.sendFile("./databases/sponsorTimes.db", { root: __dirname }); }); // Create an HTTP service. From f8340d770cd373050c75a0653d621ece03352080 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 19 Apr 2020 19:26:09 -0400 Subject: [PATCH 4/7] Fixed capitalization --- src/routes/getDaysSavedFormatted.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/getDaysSavedFormatted.js b/src/routes/getDaysSavedFormatted.js index 2f0b141..45f13d8 100644 --- a/src/routes/getDaysSavedFormatted.js +++ b/src/routes/getDaysSavedFormatted.js @@ -1,12 +1,12 @@ var db = require('../databases/databases.js').db; module.exports = function getDaysSavedFormatted (req, res) { - let row = db.prepare("select sum((endtime - starttime) / 60 / 60 / 24 * views) as dayssaved from sponsortimes where shadowhidden != 1").get(); + let row = db.prepare("SELECT SUM((endTime - startTime) / 60 / 60 / 24 * views) as daysSaved from sponsorTimes where shadowHidden != 1").get(); if (row !== undefined) { //send this result res.send({ - dayssaved: row.dayssaved.tofixed(2) + daysSaved: row.daysSaved.toFixed(2) }); } } From ad2fe00af0f333a6a42ccc559fd9a55f73647606 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 19 Apr 2020 19:39:40 -0400 Subject: [PATCH 5/7] Fixed database endpoint and getDatsSavedFormatted --- src/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index 043ce44..4ad83ff 100644 --- a/src/app.js +++ b/src/app.js @@ -82,10 +82,10 @@ app.get('/api/getTopUsers', getTopUsers); app.get('/api/getTotalStats', getTotalStats); //send out a formatted time saved total -app.get('/api/getdayssavedformatted', getDaysSavedFormatted); +app.get('/api/getDaysSavedFormatted', getDaysSavedFormatted); app.get('/database.db', function (req, res) { - res.sendFile("./databases/sponsorTimes.db", { root: __dirname }); + res.sendFile("./databases/sponsorTimes.db", { root: "./" }); }); // Create an HTTP service. From 818c288ba03e60e7eb438e9d00bfdf8b013273fc Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 19 Apr 2020 19:47:17 -0400 Subject: [PATCH 6/7] Set production mode based on config --- src/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index 4ad83ff..9561dc1 100644 --- a/src/app.js +++ b/src/app.js @@ -26,7 +26,6 @@ var getDaysSavedFormatted = require('./routes/getDaysSavedFormatted.js'); var oldGetVideoSponsorTimes = require('./routes/oldGetVideoSponsorTimes.js'); var oldSubmitSponsorTimes = require('./routes/oldSubmitSponsorTimes.js'); - //setup CORS correctly app.use(corsMiddleware); app.use(loggerMiddleware); @@ -35,6 +34,9 @@ app.use(express.json()) // Setup pretty JSON if (config.mode === "development") app.set('json spaces', 2); +// Set production mode +app.set('env', config.mode || 'production'); + //add the get function app.get('/api/getVideoSponsorTimes', oldGetVideoSponsorTimes); From a3b01e4eae3a3a668e8c7aa4ac3ff855cf2230b9 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 23 Apr 2020 11:58:36 -0400 Subject: [PATCH 7/7] Fix test process not dying --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index 3a13418..a5f09b0 100644 --- a/test.js +++ b/test.js @@ -34,7 +34,7 @@ var mockServer = createMockServer(() => { mocha.run(function(failures) { mockServer.close(); server.close(); - process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures + process.exit(failures ? 1 : 0); // exit with non-zero status if there were failures }); }); });