popular topics will use topic creation time

This commit is contained in:
barisusakli
2015-01-07 13:35:49 -05:00
parent 2d4383c7b0
commit c1ac92ac19
3 changed files with 16 additions and 14 deletions

View File

@@ -35,8 +35,13 @@ var anonCache = {}, lastUpdateTime = 0;
categoriesController.popular = function(req, res, next) {
var uid = req.user ? req.user.uid : 0;
var term = req.params.term || 'daily';
var terms = {
daily: 'day',
weekly: 'week',
monthly: 'month',
alltime: 'alltime'
};
var term = terms[req.params.term] || 'day';
if (uid === 0) {
if (anonCache[term] && (Date.now() - lastUpdateTime) < 60 * 60 * 1000) {