Skip to content

Commit

Permalink
feat(graphql-api): Sort bookmarks on latestEpisodeAired
Browse files Browse the repository at this point in the history
This way the bookmarks that have episodes aired recently will come up first
  • Loading branch information
TriPSs committed Sep 19, 2020
1 parent 3242f6e commit ff82210
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/graphql-api/src/bookmarks/bookmarks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ export class BookmarksService {
return [
...movies,
...shows
].sort((itemA, itemB) => itemB.bookmarkedOn - itemA.bookmarkedOn)
// .slice(bookmarksArgs.offset, bookmarksArgs.offset + bookmarksArgs.limit)
]
.sort((itemA, itemB) => {
console.log(itemA)
console.log(itemB)
const itemACompare = itemA?.latestEpisodeAired ?? itemA.bookmarkedOn
const itemBCompare = itemB?.latestEpisodeAired ?? itemB.bookmarkedOn

return itemBCompare - itemACompare
})
}

async findAllMovies(bookmarksArgs: BookmarksArgs): Promise<Content[]> {
Expand Down Expand Up @@ -82,7 +89,7 @@ export class BookmarksService {
bookmarked: true,
title: {
// Update the query to make it better searchable
$regex: bookmarksArgs.query.split(' ').join('.+'),
$regex: bookmarksArgs.query.trim().split(' ').join('.+'),
$options: 'i'
}
}
Expand Down

0 comments on commit ff82210

Please sign in to comment.