From d91fa5747d64f8605048941392e965afd43e4248 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 14 Aug 2014 15:19:57 -0400 Subject: [PATCH] closes #1964 --- public/language/en_GB/recent.json | 1 + src/controllers/categories.js | 4 ++-- src/topics/popular.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/public/language/en_GB/recent.json b/public/language/en_GB/recent.json index 32b31d2666..ff6400f27a 100644 --- a/public/language/en_GB/recent.json +++ b/public/language/en_GB/recent.json @@ -4,5 +4,6 @@ "week": "Week", "month": "Month", "year": "Year", + "alltime": "All Time", "no_recent_topics": "There are no recent topics." } \ No newline at end of file diff --git a/src/controllers/categories.js b/src/controllers/categories.js index 506747f741..a0fb8db212 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -17,7 +17,7 @@ categoriesController.recent = function(req, res, next) { return next(err); } - data['feeds:disableRSS'] = meta.config['feeds:disableRSS'] === '1' ? true : false; + data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; res.render('recent', data); }); @@ -33,7 +33,7 @@ categoriesController.popular = function(req, res, next) { return next(err); } - data['feeds:disableRSS'] = meta.config['feeds:disableRSS'] === '1' ? true : false; + data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; res.render('popular', {topics: data}); }); diff --git a/src/topics/popular.js b/src/topics/popular.js index dd9a8d4240..895849eae8 100644 --- a/src/topics/popular.js +++ b/src/topics/popular.js @@ -16,6 +16,10 @@ module.exports = function(Topics) { yearly: 'year' }; + if (term === 'alltime') { + return getAllTimePopular(uid, callback); + } + var since = terms[term] || 'day'; async.waterfall([ @@ -45,6 +49,12 @@ module.exports = function(Topics) { ], callback); }; + function getAllTimePopular(uid, callback) { + Topics.getTopicsFromSet(uid, 'topics:posts', 0, 19, function(err, data) { + callback(err, data ? data.topics : null); + }); + } + function getTopics(tids, uid, callback) { var keys = tids.map(function(tid) { return 'topic:' + tid;