fix upgrade script to include main post, and fix post indices

v1.18.x
barisusakli 10 years ago
parent 9a21e9646f
commit 802c8b15e2

@ -357,7 +357,7 @@ var async = require('async'),
return next(err);
}
topics = topics.map(function(topic) {
return topic && topic.postcount;
return topic && (parseInt(topic.postcount, 10) || 0);
});
next(null, topics);
@ -409,7 +409,7 @@ var async = require('async'),
var teasers = tids.map(function(tid, index) {
if (tidToPost[tid]) {
tidToPost[tid].index = results.counts[index] + 1;
tidToPost[tid].index = results.counts[index];
}
return tidToPost[tid];
});

@ -19,7 +19,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
latestSchema = Date.UTC(2014, 9, 14);
latestSchema = Date.UTC(2014, 9, 22);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@ -1114,7 +1114,7 @@ Upgrade.upgrade = function(callback) {
if (err) {
return next(err);
}
count = parseInt(count, 10) || 0;
count = (parseInt(count, 10) || 0) + 1;
winston.info('updating tid ' + tid + ' count ' + count);
db.setObjectField('topic:' + tid, 'postcount', count, next);
});
@ -1122,9 +1122,9 @@ Upgrade.upgrade = function(callback) {
});
}
thisSchemaDate = Date.UTC(2014, 9, 14);
thisSchemaDate = Date.UTC(2014, 9, 22);
if (schemaDate < thisSchemaDate) {
winston.info('[2014/10/14] Topic post count migration');
winston.info('[2014/10/22] Topic post count migration');
async.series([
function(next) {
@ -1135,14 +1135,14 @@ Upgrade.upgrade = function(callback) {
}
], function(err) {
if (err) {
winston.error('[2014/10/14] Error encountered while Topic post count migration');
winston.error('[2014/10/22] Error encountered while Topic post count migration');
return next(err);
}
winston.info('[2014/10/14] Topic post count migration done');
winston.info('[2014/10/22] Topic post count migration done');
Upgrade.update(thisSchemaDate, next);
});
} else {
winston.info('[2014/10/14] Topic post count migration skipped');
winston.info('[2014/10/22] Topic post count migration skipped');
next();
}
}

Loading…
Cancel
Save