diff --git a/controllers/statsController.js b/controllers/statsController.js index e9593c4b..ee50f970 100644 --- a/controllers/statsController.js +++ b/controllers/statsController.js @@ -144,10 +144,11 @@ module.exports = { }, getTrendingClaims (startDate) { logger.debug('retrieving trending requests'); - const deferred = new Promise((resolve, reject) => { + const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' '); + return new Promise((resolve, reject) => { // get the raw requests data db.sequelize - .query('SELECT COUNT(*), File.* FROM Request LEFT JOIN File ON Request.FileId = File.id WHERE FileId IS NOT NULL AND nsfw != 1 AND trendingEligible = 1 GROUP BY FileId ORDER BY COUNT(*) DESC LIMIT 25;', { type: db.sequelize.QueryTypes.SELECT }) + .query(`SELECT COUNT(*), File.* FROM Request LEFT JOIN File ON Request.FileId = File.id WHERE FileId IS NOT NULL AND nsfw != 1 AND trendingEligible = 1 AND Request.createdAt > "${dateTime}" GROUP BY FileId ORDER BY COUNT(*) DESC LIMIT 25;`, { type: db.sequelize.QueryTypes.SELECT }) .then(results => { resolve(results); }) @@ -156,6 +157,5 @@ module.exports = { reject(error); }); }); - return deferred; }, }; diff --git a/routes/home-routes.js b/routes/home-routes.js index 8089f947..658e4711 100644 --- a/routes/home-routes.js +++ b/routes/home-routes.js @@ -6,7 +6,7 @@ module.exports = app => { app.get('/', ({ headers, ip, originalUrl }, res) => { // get yesterday's date const startDate = new Date(); - startDate.setDate(startDate.getDate() - 1); + startDate.setDate(startDate.getDate() - 3); // send response getTrendingClaims(startDate) .then(result => {