mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
flushed out upgrade path for notifications
This commit is contained in:
@@ -11,20 +11,52 @@ Upgrade.upgrade = function() {
|
|||||||
function(next) {
|
function(next) {
|
||||||
RDB.hget('notifications:1', 'score', function(err, score) {
|
RDB.hget('notifications:1', 'score', function(err, score) {
|
||||||
if (score) {
|
if (score) {
|
||||||
winston.info('[2013/10/03] Updating Notifications');
|
async.series([
|
||||||
RDB.keys('uid:*:notifications:*', function(err, keys) {
|
function(next) {
|
||||||
async.each(keys, function(key, next) {
|
RDB.keys('uid:*:notifications:flag', function(err, keys) {
|
||||||
RDB.zrange(key, 0, -1, function(err, nids) {
|
if (keys.length > 0) {
|
||||||
async.each(nids, function(nid, next) {
|
winston.info('[2013/10/03] Removing deprecated Notification Flags');
|
||||||
notifications.get(nid, function(notif_data) {
|
async.each(keys, function(key, next) {
|
||||||
RDB.zadd(key, notif_data.datetime, nid, next);
|
RDB.del(key, next);
|
||||||
|
}, next);
|
||||||
|
} else {
|
||||||
|
winston.info('[2013/10/03] No Notification Flags found. Good.');
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
winston.info('[2013/10/03] Updating Notifications');
|
||||||
|
RDB.keys('uid:*:notifications:*', function(err, keys) {
|
||||||
|
async.each(keys, function(key, next) {
|
||||||
|
RDB.zrange(key, 0, -1, function(err, nids) {
|
||||||
|
async.each(nids, function(nid, next) {
|
||||||
|
notifications.get(nid, function(notif_data) {
|
||||||
|
RDB.zadd(key, notif_data.datetime, nid, next);
|
||||||
|
});
|
||||||
|
}, next);
|
||||||
});
|
});
|
||||||
}, next);
|
}, next);
|
||||||
});
|
});
|
||||||
}, next);
|
},
|
||||||
});
|
function(next) {
|
||||||
|
RDB.keys('notifications:*', function(err, keys) {
|
||||||
|
if (keys.length > 0) {
|
||||||
|
winston.info('[2013/10/03] Removing Notification Scores');
|
||||||
|
async.each(keys, function(key, next) {
|
||||||
|
if (key === 'notifications:next_nid') return next();
|
||||||
|
RDB.hdel(key, 'score', next);
|
||||||
|
}, next);
|
||||||
|
} else {
|
||||||
|
winston.info('[2013/10/03] No Notification Scores found. Good.');
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], next);
|
||||||
} else {
|
} else {
|
||||||
winston.info('[2013/10/03] Updates to Notifications skipped.');
|
winston.info('[2013/10/03] Updates to Notifications skipped.');
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user