Compare commits

...

1 Commits

Author SHA1 Message Date
Artem Anufrij
988afab81c fix most listened tracks. fix #19
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-27 15:20:19 +02:00

View File

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