From dfbac595b676e2d90638afbda9306565d4033556 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 29 Nov 2014 21:18:02 -0500 Subject: [PATCH] refactors to sitemap, closed #2254 --- src/sitemap.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/sitemap.js b/src/sitemap.js index dcb3c48f75..6d65719696 100644 --- a/src/sitemap.js +++ b/src/sitemap.js @@ -54,34 +54,34 @@ var path = require('path'), topicUrls: function(next) { var topicUrls = []; - db.getSortedSetRevRange('topics:recent', 0, 49, function(err, tids) { + async.waterfall([ + async.apply(db.getSortedSetRevRange, 'topics:recent', 0, -1), + function(tids, next) { + db.getSortedSetRevRange('topics:recent', 0, -1, next); + }, + function(tids, next) { + privileges.topics.filter('read', tids, 0, next); + }, + function(tids, next) { + topics.getTopicsFields(tids, ['tid', 'title', 'lastposttime'], next); + } + ], function(err, topics) { if (err) { return next(err); } - privileges.topics.filter('read', tids, 0, function(err, tids) { - if (err) { - return next(err); - } - - topics.getTopicsFields(tids, ['tid', 'title', 'lastposttime'], function(err, topics) { - if (err) { - return next(err); - } - topics.forEach(function(topic) { - if (topic) { - topicUrls.push({ - url: '/topic/' + topic.tid + '/' + encodeURIComponent(utils.slugify(topic.title)), - lastmodISO: utils.toISOString(topic.lastposttime), - changefreq: 'daily', - priority: '0.6' - }); - } + topics.forEach(function(topic) { + if (topic) { + topicUrls.push({ + url: '/topic/' + topic.tid + '/' + encodeURIComponent(utils.slugify(topic.title)), + lastmodISO: utils.toISOString(topic.lastposttime), + changefreq: 'daily', + priority: '0.6' }); - - next(null, topicUrls); - }); + } }); + + next(null, topicUrls); }); } }, function(err, data) {