revised trending to look at past 3 days

This commit is contained in:
bill bittner 2017-07-30 11:24:12 -07:00
parent 1d08a0eec6
commit 56dfc245e6
2 changed files with 4 additions and 4 deletions

View file

@ -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;
},
};

View file

@ -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 => {