mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
use '-inf'/'+inf'
This commit is contained in:
@@ -86,7 +86,7 @@ module.exports = function(Categories) {
|
|||||||
db.getSortedSetRevRangeByScore('cid:' + category.cid + ':tids', 0, -1, '+inf', Date.now(), next);
|
db.getSortedSetRevRangeByScore('cid:' + category.cid + ':tids', 0, -1, '+inf', Date.now(), next);
|
||||||
},
|
},
|
||||||
tids: function(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) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -95,7 +95,16 @@ module.exports = function(db, module) {
|
|||||||
if (!Array.isArray(keys) || !keys.length) {
|
if (!Array.isArray(keys) || !keys.length) {
|
||||||
return callback();
|
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);
|
callback(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -214,10 +214,10 @@ var async = require('async'),
|
|||||||
db.sortedSetsRemove(readKeys, notification.nid, next);
|
db.sortedSetsRemove(readKeys, notification.nid, next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
db.sortedSetsRemoveRangeByScore(unreadKeys, 0, oneWeekAgo, next);
|
db.sortedSetsRemoveRangeByScore(unreadKeys, '-inf', oneWeekAgo, next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
db.sortedSetsRemoveRangeByScore(readKeys, 0, oneWeekAgo, next);
|
db.sortedSetsRemoveRangeByScore(readKeys, '-inf', oneWeekAgo, next);
|
||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -358,7 +358,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
var cutoffTime = Date.now() - week;
|
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) {
|
if (err) {
|
||||||
return winston.error(err.message);
|
return winston.error(err.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,10 +188,9 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserNotifications.getDailyUnread = function(uid, callback) {
|
UserNotifications.getDailyUnread = function(uid, callback) {
|
||||||
var now = Date.now(),
|
var yesterday = Date.now() - (1000 * 60 * 60 * 24); // Approximate, can be more or less depending on time changes, makes no difference really.
|
||||||
yesterday = 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) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,10 +144,10 @@ var async = require('async'),
|
|||||||
function(next) {
|
function(next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
tokens: function(next) {
|
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) {
|
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);
|
}, next);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user