v1.18.x
Barış Soner Uşaklı 7 years ago
parent e779942215
commit b58387c822

@ -258,7 +258,7 @@ module.exports = function (Topics) {
if (!exists) { if (!exists) {
return next(new Error('[[error:no-topic]]')); return next(new Error('[[error:no-topic]]'));
} }
Topics.getTopicFields(tid, ['cid', 'lastposttime', 'pinned', 'deleted', 'postcount'], next); Topics.getTopicFields(tid, ['cid', 'lastposttime', 'pinned', 'deleted', 'postcount', 'upvotes', 'downvotes'], next);
}, },
function (topicData, next) { function (topicData, next) {
topic = topicData; topic = topicData;
@ -266,6 +266,7 @@ module.exports = function (Topics) {
'cid:' + topicData.cid + ':tids', 'cid:' + topicData.cid + ':tids',
'cid:' + topicData.cid + ':tids:pinned', 'cid:' + topicData.cid + ':tids:pinned',
'cid:' + topicData.cid + ':tids:posts', 'cid:' + topicData.cid + ':tids:posts',
'cid:' + topicData.cid + ':tids:votes',
'cid:' + topicData.cid + ':tids:lastposttime', 'cid:' + topicData.cid + ':tids:lastposttime',
'cid:' + topicData.cid + ':recent_tids', 'cid:' + topicData.cid + ':recent_tids',
], tid, next); ], tid, next);
@ -273,6 +274,10 @@ module.exports = function (Topics) {
function (next) { function (next) {
db.sortedSetAdd('cid:' + cid + ':tids:lastposttime', topic.lastposttime, tid, next); db.sortedSetAdd('cid:' + cid + ':tids:lastposttime', topic.lastposttime, tid, next);
}, },
function (next) {
var votes = (parseInt(topic.upvotes, 10) || 0) - (parseInt(topic.downvotes, 10) || 0);
db.sortedSetAdd('cid:' + cid + ':tids:votes', votes, tid, next);
},
function (next) { function (next) {
if (parseInt(topic.pinned, 10)) { if (parseInt(topic.pinned, 10)) {
db.sortedSetAdd('cid:' + cid + ':tids:pinned', Date.now(), tid, next); db.sortedSetAdd('cid:' + cid + ':tids:pinned', Date.now(), tid, next);

Loading…
Cancel
Save