mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closes #3611
This commit is contained in:
24
src/posts.js
24
src/posts.js
@@ -168,25 +168,13 @@ var async = require('async'),
|
||||
});
|
||||
};
|
||||
|
||||
Posts.getPidIndex = function(pid, uid, callback) {
|
||||
async.parallel({
|
||||
settings: function(next) {
|
||||
user.getSettings(uid, next);
|
||||
},
|
||||
tid: function(next) {
|
||||
Posts.getPostField(pid, 'tid', next);
|
||||
Posts.getPidIndex = function(pid, tid, topicPostSort, callback) {
|
||||
var set = topicPostSort === 'most_votes' ? 'tid:' + tid + ':posts:votes' : 'tid:' + tid + ':posts';
|
||||
db.sortedSetRank(set, pid, function(err, index) {
|
||||
if (!utils.isNumber(index)) {
|
||||
return callback(err, 0);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
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);
|
||||
}
|
||||
callback(err, parseInt(index, 10) + 2);
|
||||
});
|
||||
callback(err, parseInt(index, 10) + 1);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user