Compare commits

..

1 Commits

Author SHA1 Message Date
c2817fe0b3 Merge pull request 'main' (#20) from main into dev
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #20
2023-09-27 15:17:17 +02:00

View File

@@ -97,16 +97,9 @@ exports.mostListened = function (filter, callback) {
} }
}, { $match: { "album.visibility": { $in: filter } } }); }, { $match: { "album.visibility": { $in: filter } } });
} else { } else {
dbo.collection("history") aggregate.unshift({ $match: { type: 'track' } });
.find() }
.project({ _id: true }) aggregate.push({ $sort: { counter: -1, _id: -1 } }, { $limit: 6 })
.sort({ _id: -1 })
.limit(1000)
.toArray((err, ids) => {
let arr = ids.map(h => h._id);
aggregate.unshift({ $match: { type: 'track', _id: { $in: arr } } });
aggregate.push({ $sort: { counter: -1 } }, { $limit: 6 })
dbo dbo
.collection("history") .collection("history")
@@ -117,7 +110,4 @@ exports.mostListened = function (filter, callback) {
if (err) throw err; if (err) throw err;
callback(result); callback(result);
}); });
});
}
}; };