fix most listened tracks. fix #19
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
94007dc7da
commit
988afab81c
@ -97,17 +97,27 @@ 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
|
||||||
|
.collection("history")
|
||||||
|
.aggregate(aggregate, {
|
||||||
|
allowDiskUse: true
|
||||||
|
})
|
||||||
|
.toArray((err, result) => {
|
||||||
|
if (err) throw err;
|
||||||
|
callback(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
dbo
|
|
||||||
.collection("history")
|
|
||||||
.aggregate(aggregate, {
|
|
||||||
allowDiskUse: true
|
|
||||||
})
|
|
||||||
.toArray((err, result) => {
|
|
||||||
if (err) throw err;
|
|
||||||
callback(result);
|
|
||||||
});
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user