mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
[database/mongo] Improve speed of sortedSetRank (#6229)
* [database/mongo] Improve speed of sortedSetRank * [database/mongo] Fix sortedSetRank to filter by _key
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
c47987b305
commit
5b1ed21634
@@ -17,6 +17,9 @@ describe('Sorted Set methods', function () {
|
||||
function (next) {
|
||||
db.sortedSetAdd('sortedSetTest3', [2, 4], ['value2', 'value4'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('sortedSetTest4', [1, 1, 2, 3, 5], ['b', 'a', 'd', 'e', 'c'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('sortedSetLex', [0, 0, 0, 0], ['a', 'b', 'c', 'd'], next);
|
||||
},
|
||||
@@ -305,6 +308,33 @@ describe('Sorted Set methods', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the rank sorted by the score and then the value (a)', function (done) {
|
||||
db.sortedSetRank('sortedSetTest4', 'a', function (err, rank) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(arguments.length, 2);
|
||||
assert.equal(rank, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the rank sorted by the score and then the value (b)', function (done) {
|
||||
db.sortedSetRank('sortedSetTest4', 'b', function (err, rank) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(arguments.length, 2);
|
||||
assert.equal(rank, 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the rank sorted by the score and then the value (c)', function (done) {
|
||||
db.sortedSetRank('sortedSetTest4', 'c', function (err, rank) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(arguments.length, 2);
|
||||
assert.equal(rank, 4);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortedSetRevRank()', function () {
|
||||
|
||||
Reference in New Issue
Block a user