|
|
|
@ -10,7 +10,7 @@ var db = require('./database'),
|
|
|
|
|
schemaDate, thisSchemaDate,
|
|
|
|
|
|
|
|
|
|
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
|
|
|
|
latestSchema = Date.UTC(2016, 9, 8);
|
|
|
|
|
latestSchema = Date.UTC(2016, 9, 14);
|
|
|
|
|
|
|
|
|
|
Upgrade.check = function (callback) {
|
|
|
|
|
db.get('schemaDate', function (err, value) {
|
|
|
|
@ -907,6 +907,41 @@ Upgrade.upgrade = function (callback) {
|
|
|
|
|
winston.info('[2016/10/8] favourite -> bookmark refactor - skipped!');
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
thisSchemaDate = Date.UTC(2016, 9, 14);
|
|
|
|
|
|
|
|
|
|
if (schemaDate < thisSchemaDate) {
|
|
|
|
|
updatesMade = true;
|
|
|
|
|
winston.info('[2016/10/14] Creating sorted sets for post replies');
|
|
|
|
|
|
|
|
|
|
var posts = require('./posts');
|
|
|
|
|
var batch = require('./batch');
|
|
|
|
|
batch.processSortedSet('posts:pid', function(ids, next) {
|
|
|
|
|
posts.getPostsFields(ids, ['pid', 'toPid', 'timestamp'], function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.each(data, function(postData, next) {
|
|
|
|
|
if (!parseInt(post.toPid, 10)) {
|
|
|
|
|
return next(null);
|
|
|
|
|
}
|
|
|
|
|
db.sortedSetAdd('pid:' + postData.toPid + ':replies', postData.timestamp, postData.pid, next);
|
|
|
|
|
}, next);
|
|
|
|
|
});
|
|
|
|
|
}, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
winston.info('[2016/10/14] Creating sorted sets for post replies - done');
|
|
|
|
|
Upgrade.update(thisSchemaDate, next);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
winston.info('[2016/10/14] Creating sorted sets for post replies - skipped!');
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Add new schema updates here
|
|
|
|
|
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
|
|
|
|
|