Skip to content

Commit

Permalink
perfs: perfs: make getBestSongsNbOffseted even faster
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinguidee committed Feb 26, 2024
1 parent 160d897 commit e5fb3b2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/src/database/queries/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ export const getBestSongsNbOffseted = (
InfosModel.aggregate([
{ $match: basicMatch(user._id, start, end) },
{ $group: { _id: '$id', count: { $sum: 1 } } },
{ $sort: { count: -1, 'track.name': 1 } },
{ $skip: offset },
{ $limit: nb },
{ $lookup: lightTrackLookupPipeline('_id') },
{ $unwind: '$track' },

Expand All @@ -576,11 +579,7 @@ export const getBestSongsNbOffseted = (
},
{
$facet: {
tracks: [
{ $sort: { count: -1, 'track.name': 1 } },
{ $skip: offset },
{ $limit: nb },
],
tracks: [],
computations: [
{
$group: {
Expand Down

0 comments on commit e5fb3b2

Please sign in to comment.