faster sitemap

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 5673769c8c
commit 17ca1d33fb

@ -19,31 +19,25 @@ var sitemap = {
}; };
sitemap.render = function (callback) { sitemap.render = function (callback) {
var numTopics = parseInt(meta.config.sitemapTopics, 10) || 500; var topicsPerPage = parseInt(meta.config.sitemapTopics, 10) || 500;
var returnData = { var returnData = {
url: nconf.get('url'), url: nconf.get('url'),
topics: [], topics: [],
}; };
var numPages;
async.waterfall([ async.waterfall([
async.apply(db.getSortedSetRange, 'topics:recent', 0, 1000), function (next) {
function (tids, next) { db.getObjectField('global', 'topicCount', next);
privileges.topics.filterTids('read', tids, 0, next);
}, },
], function (err, tids) { function (topicCount, next) {
if (err) { var numPages = Math.max(0, topicCount / topicsPerPage);
numPages = 1; for (var x = 1; x <= numPages; x += 1) {
} else { returnData.topics.push(x);
numPages = Math.ceil(tids.length / numTopics); }
}
for (var x = 1; x <= numPages; x += 1) {
returnData.topics.push(x);
}
callback(null, returnData); next(null, returnData);
}); },
], callback);
}; };
sitemap.getPages = function (callback) { sitemap.getPages = function (callback) {

Loading…
Cancel
Save