feat: make upload scores descending for ordering

This commit is contained in:
Barış Soner Uşaklı
2024-06-10 11:00:45 -04:00
parent 8ded36f25d
commit 3ec44d640d

View File

@@ -163,7 +163,7 @@ module.exports = function (Posts) {
filePaths = await _filterValidPaths(filePaths); // Only process files that exist and are within uploads directory filePaths = await _filterValidPaths(filePaths); // Only process files that exist and are within uploads directory
const now = Date.now(); const now = Date.now();
const scores = filePaths.map(() => now); const scores = filePaths.map((p, i) => now + i);
const bulkAdd = filePaths.map(path => [`upload:${md5(path)}:pids`, now, pid]); const bulkAdd = filePaths.map(path => [`upload:${md5(path)}:pids`, now, pid]);
await Promise.all([ await Promise.all([
db.sortedSetAdd(`post:${pid}:uploads`, scores, filePaths), db.sortedSetAdd(`post:${pid}:uploads`, scores, filePaths),