topics.getTopics doesnt take set param

v1.18.x
barisusakli 10 years ago
parent 79265b9e83
commit 653850661e

@ -281,7 +281,7 @@ accountsController.getTopics = function(req, res, next) {
} }
var set = 'uid:' + userData.uid + ':topics'; var set = 'uid:' + userData.uid + ':topics';
topics.getTopicsFromSet(callerUID, set, 0, 19, function(err, userTopics) { topics.getTopicsFromSet(set, callerUID, 0, 19, function(err, userTopics) {
if(err) { if(err) {
return next(err); return next(err);
} }

@ -11,6 +11,7 @@ tagsController.getTag = function(req, res, next) {
var tag = validator.escape(req.params.tag); var tag = validator.escape(req.params.tag);
var uid = req.user ? req.user.uid : 0; var uid = req.user ? req.user.uid : 0;
var end = (parseInt(meta.config.topicsPerList, 10) || 20) - 1; var end = (parseInt(meta.config.topicsPerList, 10) || 20) - 1;
topics.getTagTids(tag, 0, end, function(err, tids) { topics.getTagTids(tag, 0, end, function(err, tids) {
if (err) { if (err) {
return next(err); return next(err);
@ -21,7 +22,7 @@ tagsController.getTag = function(req, res, next) {
return res.render('tag', {topics: [], tag: tag}); return res.render('tag', {topics: [], tag: tag});
} }
topics.getTopics('tag:' + tag + ':topics', uid, tids, function(err, data) { topics.getTopics(tids, uid, function(err, data) {
if (err) { if (err) {
return next(err); return next(err);
} }

@ -146,7 +146,7 @@ function disabledRSS(req, res, next) {
function generateForTopics(options, set, req, res, next) { function generateForTopics(options, set, req, res, next) {
var uid = req.user ? req.user.uid : 0; var uid = req.user ? req.user.uid : 0;
topics.getTopicsFromSet(uid, set, 0, 19, function (err, data) { topics.getTopicsFromSet(set, uid, 0, 19, function (err, data) {
if (err) { if (err) {
return next(err); return next(err);
} }

@ -485,7 +485,7 @@ SocketTopics.loadMoreFromSet = function(socket, data, callback) {
var start = parseInt(data.after, 10), var start = parseInt(data.after, 10),
end = start + 9; end = start + 9;
topics.getTopicsFromSet(socket.uid, data.set, start, end, callback); topics.getTopicsFromSet(data.set, socket.uid, start, end, callback);
}; };
SocketTopics.loadTopics = function(socket, data, callback) { SocketTopics.loadTopics = function(socket, data, callback) {
@ -493,7 +493,7 @@ SocketTopics.loadTopics = function(socket, data, callback) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));
} }
topics.getTopicsFromSet(socket.uid, data.set, data.start, data.end, callback); topics.getTopicsFromSet(data.set, socket.uid, data.start, data.end, callback);
}; };
SocketTopics.getPageCount = function(socket, tid, callback) { SocketTopics.getPageCount = function(socket, tid, callback) {

@ -107,7 +107,7 @@ var async = require('async'),
}); });
}; };
Topics.getTopics = function(set, uid, tids, callback) { Topics.getTopics = function(tids, uid, callback) {
var returnTopics = { var returnTopics = {
topics: [], topics: [],
nextStart: 0 nextStart: 0
@ -129,13 +129,13 @@ var async = require('async'),
}); });
}; };
Topics.getTopicsFromSet = function(uid, set, start, end, callback) { Topics.getTopicsFromSet = function(set, uid, start, end, callback) {
db.getSortedSetRevRange(set, start, end, function(err, tids) { db.getSortedSetRevRange(set, start, end, function(err, tids) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
Topics.getTopics(set, uid, tids, function(err, data) { Topics.getTopics(tids, uid, function(err, data) {
if (err) { if (err) {
return callback(err); return callback(err);
} }

@ -33,7 +33,7 @@ module.exports = function(Topics) {
}; };
function getAllTimePopular(uid, count, callback) { function getAllTimePopular(uid, count, callback) {
Topics.getTopicsFromSet(uid, 'topics:posts', 0, count - 1, function(err, data) { Topics.getTopicsFromSet('topics:posts', uid, 0, count - 1, function(err, data) {
callback(err, data ? data.topics : null); callback(err, data ? data.topics : null);
}); });
} }

@ -16,18 +16,7 @@ module.exports = function(Topics) {
}; };
Topics.getRecentTopics = function(uid, start, end, callback) { Topics.getRecentTopics = function(uid, start, end, callback) {
async.waterfall([ Topics.getTopicsFromSet('topics:recent', uid, start, end, callback);
function(next) {
db.getSortedSetRevRange('topics:recent', start, end, next);
},
function(tids, next) {
Topics.getTopics('topics:recent', uid, tids, next);
},
function(data, next) {
data.nextStart = end + 1;
next(null, data);
}
], callback);
}; };
Topics.getLatestTopics = function(uid, start, end, term, callback) { Topics.getLatestTopics = function(uid, start, end, term, callback) {
@ -36,7 +25,7 @@ module.exports = function(Topics) {
return callback(err); return callback(err);
} }
Topics.getTopics('topics:recent', uid, tids, function(err, data) { Topics.getTopics(tids, uid, function(err, data) {
if (err) { if (err) {
return callback(err); return callback(err);
} }

Loading…
Cancel
Save