Merge remote-tracking branch 'refs/remotes/origin/master' into develop

v1.18.x
Baris Usakli 7 years ago
commit 43bec4cb45

@ -216,6 +216,9 @@ module.exports = function (Categories) {
function (next) {
db.sortedSetAdd('cid:' + cid + ':pids', postData.timestamp, postData.pid, next);
},
function (next) {
db.sortedSetAdd('cid:' + cid + ':tids:lastposttime', postData.timestamp, postData.tid, next);
},
function (next) {
db.incrObjectField('category:' + cid, 'post_count', next);
},

@ -195,6 +195,7 @@ module.exports = function (Topics) {
'cid:' + topicData.cid + ':tids',
'cid:' + topicData.cid + ':tids:pinned',
'cid:' + topicData.cid + ':tids:posts',
'cid:' + topicData.cid + ':tids:lastposttime',
'cid:' + topicData.cid + ':recent_tids',
'cid:' + topicData.cid + ':uid:' + topicData.uid + ':tids',
'uid:' + topicData.uid + ':topics',

@ -28,7 +28,13 @@ module.exports = function (Topics) {
}
async.waterfall([
function (next) {
db.getSortedSetRevRange('topics:recent', 0, 199, next);
var key = 'topics:recent';
if (cid) {
key = cid.map(function (cid) {
return 'cid:' + cid + ':tids:lastposttime';
});
}
db.getSortedSetRevRange(key, 0, 199, next);
},
function (tids, next) {
filterTids(tids, uid, filter, cid, next);
@ -119,12 +125,17 @@ module.exports = function (Topics) {
Topics.updateTimestamp = function (tid, timestamp, callback) {
async.parallel([
function (next) {
var topicData;
async.waterfall([
function (next) {
Topics.getTopicField(tid, 'deleted', next);
Topics.getTopicFields(tid, ['cid', 'deleted'], next);
},
function (_topicData, next) {
topicData = _topicData;
db.sortedSetAdd('cid:' + topicData.cid + ':tids:lastposttime', timestamp, tid, next);
},
function (deleted, next) {
if (parseInt(deleted, 10) === 1) {
function (next) {
if (parseInt(topicData.deleted, 10) === 1) {
return next();
}
Topics.updateRecent(tid, timestamp, next);

@ -263,9 +263,13 @@ module.exports = function (Topics) {
'cid:' + topicData.cid + ':tids',
'cid:' + topicData.cid + ':tids:pinned',
'cid:' + topicData.cid + ':tids:posts',
'cid:' + topicData.cid + ':tids:lastposttime',
'cid:' + topicData.cid + ':recent_tids',
], tid, next);
},
function (next) {
db.sortedSetAdd('cid:' + cid + ':tids:lastposttime', topic.lastposttime, tid, next);
},
function (next) {
if (parseInt(topic.pinned, 10)) {
db.sortedSetAdd('cid:' + cid + ':tids:pinned', Date.now(), tid, next);

@ -195,8 +195,8 @@ Upgrade.process = function (files, skipCount, callback) {
], callback);
};
Upgrade.incrementProgress = function () {
this.current += 1;
Upgrade.incrementProgress = function (value) {
this.current += value || 1;
// Redraw the progress bar
var percentage = 0;

@ -0,0 +1,29 @@
'use strict';
var async = require('async');
var db = require('../../database');
module.exports = {
name: 'New sorted set cid:<cid>:tids:lastposttime',
timestamp: Date.UTC(2017, 9, 30),
method: function (callback) {
var progress = this.progress;
require('../../batch').processSortedSet('topics:tid', function (tids, next) {
async.eachSeries(tids, function (tid, next) {
db.getObjectFields('topic:' + tid, ['cid', 'timestamp', 'lastposttime'], function (err, topicData) {
if (err || !topicData) {
return next(err);
}
progress.incr();
var timestamp = topicData.lastposttime || topicData.timestamp || Date.now();
db.sortedSetAdd('cid:' + topicData.cid + ':tids:lastposttime', timestamp, tid, next);
}, next);
}, next);
}, {
progress: this.progress,
}, callback);
},
};
Loading…
Cancel
Save