mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 03:28:57 +02:00
closes #4801
This commit is contained in:
@@ -228,7 +228,11 @@ var plugins = require('./plugins');
|
||||
async.parallel([
|
||||
function (next) {
|
||||
if (postData.uid) {
|
||||
db.sortedSetAdd('uid:' + postData.uid + ':posts:votes', postData.votes, postData.pid, next);
|
||||
if (postData.votes > 0) {
|
||||
db.sortedSetAdd('uid:' + postData.uid + ':posts:votes', postData.votes, postData.pid, next);
|
||||
} else {
|
||||
db.sortedSetRemove('uid:' + postData.uid + ':posts:votes', postData.pid, next);
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ var db = require('./database'),
|
||||
schemaDate, thisSchemaDate,
|
||||
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
latestSchema = Date.UTC(2016, 6, 12);
|
||||
latestSchema = Date.UTC(2016, 7, 5);
|
||||
|
||||
Upgrade.check = function(callback) {
|
||||
db.get('schemaDate', function(err, value) {
|
||||
@@ -657,6 +657,31 @@ Upgrade.upgrade = function(callback) {
|
||||
winston.info('[2016/07/12] Upload privileges skipped!');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2016, 7, 5);
|
||||
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
winston.info('[2016/08/05] Removing best posts with negative scores');
|
||||
var batch = require('./batch');
|
||||
batch.processSortedSet('users:joindate', function(ids, next) {
|
||||
async.each(ids, function(id, next) {
|
||||
console.log('processing uid ' + id);
|
||||
db.sortedSetsRemoveRangeByScore(['uid:' + id + ':posts:votes'], '-inf', 0, next);
|
||||
}, next);
|
||||
}, {}, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
winston.info('[2016/08/05] Removing best posts with negative scores done!');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
});
|
||||
|
||||
} else {
|
||||
winston.info('[2016/08/05] Removing best posts with negative scores skipped!');
|
||||
next();
|
||||
}
|
||||
}
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
|
||||
|
||||
Reference in New Issue
Block a user