mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	use the first set for sorting
This commit is contained in:
		| @@ -90,7 +90,10 @@ module.exports = function (Categories) { | |||||||
| 				var stop = data.stop === -1 ? data.stop : start + normalTidsToGet - 1; | 				var stop = data.stop === -1 ? data.stop : start + normalTidsToGet - 1; | ||||||
|  |  | ||||||
| 				if (Array.isArray(set)) { | 				if (Array.isArray(set)) { | ||||||
| 					db[direction === 'highest-to-lowest' ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop }, next); | 					var weights = set.map(function (s, index) { | ||||||
|  | 						return index ? 0 : 1; | ||||||
|  | 					}); | ||||||
|  | 					db[direction === 'highest-to-lowest' ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop, weights: weights }, next); | ||||||
| 				} else { | 				} else { | ||||||
| 					db[direction === 'highest-to-lowest' ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next); | 					db[direction === 'highest-to-lowest' ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next); | ||||||
| 				} | 				} | ||||||
|   | |||||||
| @@ -661,6 +661,18 @@ describe('Sorted Set methods', function () { | |||||||
| 			}); | 			}); | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
|  | 		it('should return the reverse intersection of two sets', function (done) { | ||||||
|  | 			db.getSortedSetRevIntersect({ | ||||||
|  | 				sets: ['interSet1', 'interSet2'], | ||||||
|  | 				start: 0, | ||||||
|  | 				stop: 2, | ||||||
|  | 			}, function (err, data) { | ||||||
|  | 				assert.ifError(err); | ||||||
|  | 				assert.deepEqual(['value3', 'value2'], data); | ||||||
|  | 				done(); | ||||||
|  | 			}); | ||||||
|  | 		}); | ||||||
|  |  | ||||||
| 		it('should return the intersection of two sets with scores aggregate MIN', function (done) { | 		it('should return the intersection of two sets with scores aggregate MIN', function (done) { | ||||||
| 			db.getSortedSetIntersect({ | 			db.getSortedSetIntersect({ | ||||||
| 				sets: ['interSet1', 'interSet2'], | 				sets: ['interSet1', 'interSet2'], | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user