mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
added getSortedSetRevUnion... just because.
This commit is contained in:
@@ -75,6 +75,18 @@ module.exports = function(redisClient, module) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.getSortedSetUnion = function(sets, start, stop, callback) {
|
module.getSortedSetUnion = function(sets, start, stop, callback) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 0);
|
||||||
|
args.unshift(null);
|
||||||
|
sortedSetUnion.apply(null, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.getSortedSetRevUnion = function(sets, start, stop, callback) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 0);
|
||||||
|
args.unshift(true);
|
||||||
|
sortedSetUnion.apply(null, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sortedSetUnion = function(rev, sets, start, stop, callback) {
|
||||||
// start and stop optional
|
// start and stop optional
|
||||||
if (typeof start === 'function') {
|
if (typeof start === 'function') {
|
||||||
callback = start;
|
callback = start;
|
||||||
@@ -92,7 +104,7 @@ module.exports = function(redisClient, module) {
|
|||||||
sets.unshift('temp');
|
sets.unshift('temp');
|
||||||
|
|
||||||
multi.zunionstore.apply(multi, sets);
|
multi.zunionstore.apply(multi, sets);
|
||||||
multi.zrange('temp', start, stop);
|
multi[rev ? 'zrevrange' : 'zrange']('temp', start, stop);
|
||||||
multi.del('temp');
|
multi.del('temp');
|
||||||
multi.exec(function(err, results) {
|
multi.exec(function(err, results) {
|
||||||
if (!err && typeof callback === 'function') {
|
if (!err && typeof callback === 'function') {
|
||||||
|
|||||||
@@ -330,6 +330,12 @@ describe('Test database', function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSortedSetRevUnion(callback) {
|
||||||
|
db.getSortedSetUnion(['users:joindate', 'users:derp', 'users:postcount'], function(err, data) {
|
||||||
|
callback(err, {'sortedSetUnion': data});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var sortedSetTasks = [
|
var sortedSetTasks = [
|
||||||
sortedSetAdd,
|
sortedSetAdd,
|
||||||
sortedSetAdd,
|
sortedSetAdd,
|
||||||
@@ -344,7 +350,8 @@ describe('Test database', function() {
|
|||||||
sortedSetScore,
|
sortedSetScore,
|
||||||
sortedSetsScore,
|
sortedSetsScore,
|
||||||
getSortedSetRevRangeByScore,
|
getSortedSetRevRangeByScore,
|
||||||
getSortedSetUnion
|
getSortedSetUnion,
|
||||||
|
getSortedSetRevUnion
|
||||||
];
|
];
|
||||||
|
|
||||||
async.series(sortedSetTasks, function(err, results) {
|
async.series(sortedSetTasks, function(err, results) {
|
||||||
|
|||||||
Reference in New Issue
Block a user