use '-inf'/'+inf'

v1.18.x
barisusakli 9 years ago
parent 4b531cb655
commit b0151502c2

@ -86,7 +86,7 @@ module.exports = function(Categories) {
db.getSortedSetRevRangeByScore('cid:' + category.cid + ':tids', 0, -1, '+inf', Date.now(), next);
},
tids: function(next) {
db.getSortedSetRevRangeByScore('cid:' + category.cid + ':tids', 0, Math.max(1, count), Date.now(), 0, next);
db.getSortedSetRevRangeByScore('cid:' + category.cid + ':tids', 0, Math.max(1, count), Date.now(), '-inf', next);
}
}, function(err, results) {
if (err) {

@ -95,7 +95,16 @@ module.exports = function(db, module) {
if (!Array.isArray(keys) || !keys.length) {
return callback();
}
db.collection('objects').remove({_key: {$in: keys}, score: {$lte: max, $gte: min}}, function(err) {
var scoreQuery = {};
if (min !== '-inf') {
scoreQuery.$gte = min;
}
if (max !== '+inf') {
scoreQuery.$lte = max;
}
db.collection('objects').remove({_key: {$in: keys}, score: scoreQuery}, function(err) {
callback(err);
});
};

@ -214,10 +214,10 @@ var async = require('async'),
db.sortedSetsRemove(readKeys, notification.nid, next);
},
function(next) {
db.sortedSetsRemoveRangeByScore(unreadKeys, 0, oneWeekAgo, next);
db.sortedSetsRemoveRangeByScore(unreadKeys, '-inf', oneWeekAgo, next);
},
function(next) {
db.sortedSetsRemoveRangeByScore(readKeys, 0, oneWeekAgo, next);
db.sortedSetsRemoveRangeByScore(readKeys, '-inf', oneWeekAgo, next);
}
], function(err) {
if (err) {
@ -358,7 +358,7 @@ var async = require('async'),
var cutoffTime = Date.now() - week;
db.getSortedSetRangeByScore('notifications', 0, 500, 0, cutoffTime, function(err, nids) {
db.getSortedSetRangeByScore('notifications', 0, 500, '-inf', cutoffTime, function(err, nids) {
if (err) {
return winston.error(err.message);
}

@ -188,10 +188,9 @@ var async = require('async'),
}
UserNotifications.getDailyUnread = function(uid, callback) {
var now = Date.now(),
yesterday = now - (1000*60*60*24); // Approximate, can be more or less depending on time changes, makes no difference really.
var yesterday = Date.now() - (1000 * 60 * 60 * 24); // Approximate, can be more or less depending on time changes, makes no difference really.
db.getSortedSetRevRangeByScore('uid:' + uid + ':notifications:unread', 0, 20, now, yesterday, function(err, nids) {
db.getSortedSetRevRangeByScore('uid:' + uid + ':notifications:unread', 0, 20, '+inf', yesterday, function(err, nids) {
if (err) {
return callback(err);
}

@ -144,10 +144,10 @@ var async = require('async'),
function(next) {
async.parallel({
tokens: function(next) {
db.getSortedSetRangeByScore('reset:issueDate', 0, -1, 0, Date.now() - twoHours, next);
db.getSortedSetRangeByScore('reset:issueDate', 0, -1, '-inf', Date.now() - twoHours, next);
},
uids: function(next) {
db.getSortedSetRangeByScore('reset:issueDate:uid', 0, -1, 0, Date.now() - twoHours, next);
db.getSortedSetRangeByScore('reset:issueDate:uid', 0, -1, '-inf', Date.now() - twoHours, next);
}
}, next);
},

Loading…
Cancel
Save