mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
properly filter /unread /recent /popular /top (#7927)
* feat: add failing test for pagination * feat: test * fix: redis tests * refactor: remove logs * fix: add new test * feat: make sortedSetRangeByScore work with keys on redis * fix: hardcoded set name * feat: show topics from readable categories on recent/popular/top * feat: rewrite unread topics respect watched categories and followed topics * fix: term + watched
This commit is contained in:
committed by
GitHub
parent
17437897f9
commit
310c6fd33f
@@ -227,22 +227,11 @@ describe('Sorted Set methods', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return duplicates if two sets have same elements', function (done) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.sortedSetAdd('dupezset1', [1, 2], ['value 1', 'value 2'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('dupezset2', [2, 3], ['value 2', 'value 3'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.getSortedSetRange(['dupezset1', 'dupezset2'], 0, -1, next);
|
||||
},
|
||||
function (data, next) {
|
||||
assert.deepStrictEqual(data, ['value 1', 'value 2', 'value 2', 'value 3']);
|
||||
next();
|
||||
},
|
||||
], done);
|
||||
it('should return duplicates if two sets have same elements', async function () {
|
||||
await db.sortedSetAdd('dupezset1', [1, 2], ['value 1', 'value 2']);
|
||||
await db.sortedSetAdd('dupezset2', [2, 3], ['value 2', 'value 3']);
|
||||
const data = await db.getSortedSetRange(['dupezset1', 'dupezset2'], 0, -1);
|
||||
assert.deepStrictEqual(data, ['value 1', 'value 2', 'value 2', 'value 3']);
|
||||
});
|
||||
|
||||
it('should return correct number of elements', async function () {
|
||||
@@ -405,6 +394,15 @@ describe('Sorted Set methods', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with an array of keys', async function () {
|
||||
await db.sortedSetAddBulk([
|
||||
['byScoreWithScoresKeys1', 1, 'value1'],
|
||||
['byScoreWithScoresKeys2', 2, 'value2'],
|
||||
]);
|
||||
const data = await db.getSortedSetRevRangeByScoreWithScores(['byScoreWithScoresKeys1', 'byScoreWithScoresKeys2'], 0, -1, 5, -5);
|
||||
assert.deepStrictEqual(data, [{ value: 'value2', score: 2 }, { value: 'value1', score: 1 }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortedSetCount()', function () {
|
||||
|
||||
Reference in New Issue
Block a user