This commit is contained in:
barisusakli
2014-08-17 00:14:45 -04:00
parent 5ae7c92d55
commit 05fdc945f3
7 changed files with 84 additions and 36 deletions

View File

@@ -522,13 +522,20 @@ var async = require('async'),
});
}
Posts.getPidIndex = function(pid, callback) {
Posts.getPostField(pid, 'tid', function(err, tid) {
Posts.getPidIndex = function(pid, uid, callback) {
async.parallel({
settings: function(next) {
user.getSettings(uid, next);
},
tid: function(next) {
Posts.getPostField(pid, 'tid', next);
}
}, function(err, results) {
if(err) {
return callback(err);
}
db.sortedSetRank('tid:' + tid + ':posts', pid, function(err, index) {
var set = results.settings.topicPostSort === 'most_votes' ? 'tid:' + results.tid + ':posts:votes' : 'tid:' + results.tid + ':posts';
db.sortedSetRank(set, pid, function(err, index) {
if (!utils.isNumber(index)) {
return callback(err, 1);
}