Skip to content

Commit

Permalink
much faster sitemap
Browse files Browse the repository at this point in the history
no need to load all the data, when we only use slug and lastposttime
  • Loading branch information
barisusakli committed Oct 8, 2014
1 parent e1f6705 commit 006322f
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/sitemap.js
Expand Up @@ -5,8 +5,10 @@ var path = require('path'),
sm = require('sitemap'),
url = require('url'),
nconf = require('nconf'),
db = require('./database'),
categories = require('./categories'),
topics = require('./topics'),
privileges = require('./privileges'),
utils = require('../public/src/utils'),
sitemap = {
obj: undefined,
Expand Down Expand Up @@ -49,21 +51,33 @@ var path = require('path'),
},
function(next) {
var topicUrls = [];
topics.getTopicsFromSet(0, 'topics:recent', 0, 49, function(err, data) {

db.getSortedSetRevRange('topics:recent', 0, 49, function(err, tids) {
if (err) {
return next(err);
}
privileges.topics.filter('read', tids, 0, function(err, tids) {
if (err) {
return next(err);
}

topics.getTopicsFields(tids, ['slug', 'lastposttime'], function(err, topics) {
if (err) {
return next(err);
}

data.topics.forEach(function(topic) {
topicUrls.push({
url: path.join('/topic', topic.slug),
lastmodISO: utils.toISOString(topic.lastposttime),
changefreq: 'daily',
priority: '0.6'
topics.forEach(function(topic) {
topicUrls.push({
url: path.join('/topic', topic.slug),
lastmodISO: utils.toISOString(topic.lastposttime),
changefreq: 'daily',
priority: '0.6'
});
});

next(null, topicUrls);
});
});

next(null, topicUrls);
});
}
], function(err, data) {
Expand Down

0 comments on commit 006322f

Please sign in to comment.