mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
Squashed commit of the following:
commit4e0e792232Merge:24d0999fb570b4a0e2aeAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Fri Jun 7 19:26:49 2024 -0400 Merge branch 'master' into develop commit70b4a0e2aeAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Fri Jun 7 19:14:13 2024 -0400 feat: allow passing min,max to sortedSetsCardSum to get rid of multiple db calls in profile page commit6bbe3d1c4cAuthor: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Fri Jun 7 14:08:48 2024 -0400 fix: dont show error alert when user user mouse overs votes if they dont have permission to view votes commit24d0999fb5Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Thu Jun 6 13:49:14 2024 -0400 fix(deps): update dependency pg-cursor to v2.11.0 (#12617) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commitbee05fe212Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Thu Jun 6 13:28:59 2024 -0400 fix(deps): update dependency pg to v8.12.0 (#12616) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,29 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const db = require('../mocks/databasemock');
|
||||
|
||||
describe('Sorted Set methods', () => {
|
||||
before((done) => {
|
||||
async.parallel([
|
||||
function (next) {
|
||||
db.sortedSetAdd('sortedSetTest1', [1.1, 1.2, 1.3], ['value1', 'value2', 'value3'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('sortedSetTest2', [1, 4], ['value1', 'value4'], next);
|
||||
},
|
||||
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);
|
||||
},
|
||||
], done);
|
||||
before(async () => {
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('sortedSetTest1', [1.1, 1.2, 1.3], ['value1', 'value2', 'value3']),
|
||||
db.sortedSetAdd('sortedSetTest2', [1, 4], ['value1', 'value4']),
|
||||
db.sortedSetAdd('sortedSetTest3', [2, 4], ['value2', 'value4']),
|
||||
db.sortedSetAdd('sortedSetTest4', [1, 1, 2, 3, 5], ['b', 'a', 'd', 'e', 'c']),
|
||||
db.sortedSetAdd('sortedSetLex', [0, 0, 0, 0], ['a', 'b', 'c', 'd']),
|
||||
]);
|
||||
});
|
||||
|
||||
describe('sortedSetScan', () => {
|
||||
@@ -617,6 +605,23 @@ describe('Sorted Set methods', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with min/max', async () => {
|
||||
let count = await db.sortedSetsCardSum([
|
||||
'sortedSetTest1', 'sortedSetTest2', 'sortedSetTest3',
|
||||
], '-inf', 2);
|
||||
assert.strictEqual(count, 5);
|
||||
|
||||
count = await db.sortedSetsCardSum([
|
||||
'sortedSetTest1', 'sortedSetTest2', 'sortedSetTest3',
|
||||
], 2, '+inf');
|
||||
assert.strictEqual(count, 3);
|
||||
|
||||
count = await db.sortedSetsCardSum([
|
||||
'sortedSetTest1', 'sortedSetTest2', 'sortedSetTest3',
|
||||
], '-inf', '+inf');
|
||||
assert.strictEqual(count, 7);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortedSetRank()', () => {
|
||||
@@ -1225,11 +1230,11 @@ describe('Sorted Set methods', () => {
|
||||
});
|
||||
|
||||
describe('sortedSetsRemove()', () => {
|
||||
before((done) => {
|
||||
async.parallel([
|
||||
async.apply(db.sortedSetAdd, 'sorted4', [1, 2], ['value1', 'value2']),
|
||||
async.apply(db.sortedSetAdd, 'sorted5', [1, 2], ['value1', 'value3']),
|
||||
], done);
|
||||
before(async () => {
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('sorted4', [1, 2], ['value1', 'value2']),
|
||||
db.sortedSetAdd('sorted5', [1, 2], ['value1', 'value3']),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should remove element from multiple sorted sets', (done) => {
|
||||
@@ -1278,15 +1283,11 @@ describe('Sorted Set methods', () => {
|
||||
});
|
||||
|
||||
describe('getSortedSetIntersect', () => {
|
||||
before((done) => {
|
||||
async.parallel([
|
||||
function (next) {
|
||||
db.sortedSetAdd('interSet1', [1, 2, 3], ['value1', 'value2', 'value3'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('interSet2', [4, 5, 6], ['value2', 'value3', 'value5'], next);
|
||||
},
|
||||
], done);
|
||||
before(async () => {
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('interSet1', [1, 2, 3], ['value1', 'value2', 'value3']),
|
||||
db.sortedSetAdd('interSet2', [4, 5, 6], ['value2', 'value3', 'value5']),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return the intersection of two sets', (done) => {
|
||||
@@ -1446,21 +1447,13 @@ describe('Sorted Set methods', () => {
|
||||
});
|
||||
|
||||
describe('sortedSetIntersectCard', () => {
|
||||
before((done) => {
|
||||
async.parallel([
|
||||
function (next) {
|
||||
db.sortedSetAdd('interCard1', [0, 0, 0], ['value1', 'value2', 'value3'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('interCard2', [0, 0, 0], ['value2', 'value3', 'value4'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('interCard3', [0, 0, 0], ['value3', 'value4', 'value5'], next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('interCard4', [0, 0, 0], ['value4', 'value5', 'value6'], next);
|
||||
},
|
||||
], done);
|
||||
before(async () => {
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('interCard1', [0, 0, 0], ['value1', 'value2', 'value3']),
|
||||
db.sortedSetAdd('interCard2', [0, 0, 0], ['value2', 'value3', 'value4']),
|
||||
db.sortedSetAdd('interCard3', [0, 0, 0], ['value3', 'value4', 'value5']),
|
||||
db.sortedSetAdd('interCard4', [0, 0, 0], ['value4', 'value5', 'value6']),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return # of elements in intersection', (done) => {
|
||||
|
||||
Reference in New Issue
Block a user