Skip to content

Commit

Permalink
fix: use media object lastUpdated for sorting (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnugent authored Jul 14, 2023
1 parent 8bf4c4f commit 9b0b35b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/model/MediaDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ export default class MediaDataSource extends MongoDataSource<MediaObject> {
...toIncludeMediaWithTagsOrNotfilters,
{
/**
* Sort by most recently uploaded media first
* Sort by most recently tags media
*/
$sort: { createdAt: -1, _id: -1 }
$sort: { updatedAt: -1, _id: -1 }
},
{
/**
* Limit the most recent list. While unlikely, it may be
* possible that most recent tags belong to one user.
* We want this number to be large (to pick up more users).
*/
$limit: 100
},
{
$group: {
Expand All @@ -75,6 +83,9 @@ export default class MediaDataSource extends MongoDataSource<MediaObject> {
mediaWithTags: { $push: '$$ROOT' }
}
},
{
$sort: { 'mediaWithTags.0.updatedAt': -1 }
},
{
$limit: safeMaxUsers
},
Expand Down

0 comments on commit 9b0b35b

Please sign in to comment.