Node.js based forum software built for the modern web
closes #4801
barisusakli84025fa7fc17
diff --git a/src/posts.js b/src/posts.jsindex 8a494be7c7..7062052433 100644--- a/src/posts.js+++ b/src/posts.js@@ -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();}diff --git a/src/upgrade.js b/src/upgrade.jsindex 16362883d2..dc4af652c9 100644--- a/src/upgrade.js+++ b/src/upgrade.js@@ -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!!!