Skip to content
Permalink
Browse files

much faster sitemap

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 006322f3863f5dabbc9b4051cac6b0f466e37916
Showing with 23 additions and 9 deletions.
  1. +23 −9 src/sitemap.js
@@ -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,
@@ -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) {

0 comments on commit 006322f

Please sign in to comment.
You can’t perform that action at this time.