Node.js based forum software built for the modern web
use '-inf'/'+inf'
barisusaklib0151502c24f
diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.jsindex c85bd5a69a..7d42f053ff 100644--- a/src/categories/recentreplies.js+++ b/src/categories/recentreplies.js@@ -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) {diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.jsindex db1c698e0b..d209f3f491 100644--- a/src/database/mongo/sorted.js+++ b/src/database/mongo/sorted.js@@ -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);});};diff --git a/src/notifications.js b/src/notifications.jsindex 0e73b34723..af88fd7b5b 100644--- a/src/notifications.js+++ b/src/notifications.js@@ -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);}diff --git a/src/user/notifications.js b/src/user/notifications.jsindex b04cd8ba75..9ad100db2b 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -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);}diff --git a/src/user/reset.js b/src/user/reset.jsindex 808e7d1f41..222e988de6 100644--- a/src/user/reset.js+++ b/src/user/reset.js@@ -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);},