upgrade topics:tid to sorted set, topics:recent doesnt have deleted topics

This commit is contained in:
Baris Soner Usakli
2014-02-14 14:03:54 -05:00
parent 8506819a7d
commit 1e44ca3a0f
5 changed files with 53 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ var db = require('./database'),
Upgrade.check = function(callback) {
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
var latestSchema = new Date(2014, 1, 9, 20, 50).getTime();
var latestSchema = new Date(2014, 1, 14, 20, 50).getTime();
db.get('schemaDate', function(err, value) {
if (parseInt(value, 10) >= latestSchema) {
@@ -579,7 +579,41 @@ Upgrade.upgrade = function(callback) {
winston.info('[2014/2/9] Remove Topic LastFeedUpdate value, as feeds are now on-demand - skipped');
next();
}
}
},
function(next) {
thisSchemaDate = new Date(2014, 1, 14, 20, 50).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
db.getSetMembers('topics:tid', function(err, tids) {
if(err) {
return next(err);
}
db.delete('topics:tid', function(err) {
if(err) {
return next(err);
}
async.each(tids, function(tid, next) {
Topics.getTopicField(tid, 'timestamp', function(err, timestamp) {
db.sortedSetAdd('topics:tid', timestamp, tid, next);
});
}, function(err) {
if(err) {
return next(err);
}
winston.info('[2014/2/14] Upgraded topics to sorted set');
next();
})
});
})
} else {
winston.info('[2014/2/14] Upgrade topics to sorted set - skipped');
next();
}
},
// Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!
], function(err) {