function next thisSchemaDate Date UTC 2014 11 20 if schemaDate thisSch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function(next) {
thisSchemaDate = Date.UTC(2014, 11, 20);
if (schemaDate < thisSchemaDate) {
winston.info('[2014/12/20] Updating digest settings');
async.waterfall([
async.apply(db.getSortedSetRange, 'users:joindate', 0, -1),
async.apply(User.getMultipleUserSettings)
], function(err, userSettings) {
if (err) {
winston.error('[2014/12/20] Error encountered while updating digest settings');
return next(err);
}
var now = Date.now();
async.eachLimit(userSettings, 50, function(setting, next) {
if (setting.dailyDigestFreq !== 'off') {
db.sortedSetAdd('digest:' + setting.dailyDigestFreq + ':uids', now, setting.uid, next);
} else {
next(false);
}
}, function(err) {
if (err) {
winston.error('[2014/12/20] Error encountered while updating digest settings');
return next(err);
}
winston.info('[2014/12/20] Updating digest settings done');
Upgrade.update(thisSchemaDate, next);
});
});
} else {
winston.info('[2014/12/20] Updating digest settings skipped');
next();
}
}