Skip to content

Commit

Permalink
Merge pull request #4116 from Roardom/episode-season-order-desc
Browse files Browse the repository at this point in the history
(Update) Order by season/episode descending
  • Loading branch information
HDVinnie authored Aug 30, 2024
2 parents a6be766 + 62b49a4 commit dff9f69
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
9 changes: 4 additions & 5 deletions app/Http/Livewire/SimilarTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,19 @@ final public function torrents(): \Illuminate\Support\Collection
'Complete Pack' => $this->groupByTypeAndSort($packOrSpecialOrSeasons),
'Specials' => $packOrSpecialOrSeasons
->groupBy(fn ($torrent) => 'Special '.$torrent->episode_number)
->sortKeys(SORT_NATURAL)
->sortKeysDesc(SORT_NATURAL)
->map(fn ($episode) => $this->groupByTypeAndSort($episode)),
'Seasons' => $packOrSpecialOrSeasons
->groupBy(fn ($torrent) => 'Season '.$torrent->season_number)
->sortKeys(SORT_NATURAL)
->sortKeysDesc(SORT_NATURAL)
->map(
fn ($season) => $season
->groupBy(fn ($torrent) => $torrent->episode_number === 0 ? 'Season Pack' : 'Episodes')
->map(fn ($packOrEpisodes, $key) => match ($key) {
'Season Pack' => $this->groupByTypeAndSort($packOrEpisodes),
'Episodes' => $packOrEpisodes
->groupBy(fn ($torrent) => 'Episode '.$torrent->episode_number)
->sortKeys(SORT_NATURAL)
->sortKeysDesc(SORT_NATURAL)
->map(fn ($episode) => $this->groupByTypeAndSort($episode)),
default => abort(500, 'Group found that isn\'t one of: Season Pack, Episodes.'),
})
Expand All @@ -365,8 +365,7 @@ private function groupByTypeAndSort(\Illuminate\Support\Collection $torrents): \
fn ($torrentsBytype) => $torrentsBytype
->sortBy([
['resolution.position', 'asc'],
['internal', 'desc'],
['size', 'desc']
['name', 'asc'],
])
->values()
);
Expand Down
9 changes: 4 additions & 5 deletions app/Http/Livewire/TorrentSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,19 +609,19 @@ function ($tv) {
'Complete Pack' => $this->groupByTypeAndSort($packOrSpecialOrSeasons),
'Specials' => $packOrSpecialOrSeasons
->groupBy(fn ($torrent) => 'Special '.$torrent->episode_number)
->sortKeys(SORT_NATURAL)
->sortKeysDesc(SORT_NATURAL)
->map(fn ($episode) => $this->groupByTypeAndSort($episode)),
'Seasons' => $packOrSpecialOrSeasons
->groupBy(fn ($torrent) => 'Season '.$torrent->season_number)
->sortKeys(SORT_NATURAL)
->sortKeysDesc(SORT_NATURAL)
->map(
fn ($season) => $season
->groupBy(fn ($torrent) => $torrent->episode_number === 0 ? 'Season Pack' : 'Episodes')
->map(fn ($packOrEpisodes, $key) => match ($key) {
'Season Pack' => $this->groupByTypeAndSort($packOrEpisodes),
'Episodes' => $packOrEpisodes
->groupBy(fn ($torrent) => 'Episode '.$torrent->episode_number)
->sortKeys(SORT_NATURAL)
->sortKeysDesc(SORT_NATURAL)
->map(fn ($episode) => $this->groupByTypeAndSort($episode)),
default => abort(500, 'Group found that isn\'t one of: Season Pack, Episodes.'),
})
Expand Down Expand Up @@ -684,8 +684,7 @@ private function groupByTypeAndSort($torrents): \Illuminate\Support\Collection
fn ($torrentsBytype) => $torrentsBytype
->sortBy([
['resolution.position', 'asc'],
['internal', 'desc'],
['size', 'desc']
['name', 'asc'],
])
->values()
);
Expand Down
6 changes: 3 additions & 3 deletions resources/views/components/tv/card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class="torrent-search--grouped__dropdown"
@foreach ($media->torrents['Specials'] as $specialName => $special)
<details
class="torrent-search--grouped__dropdown"
@if ($loop->last)
@if ($loop->first)
open
@endif
>
Expand Down Expand Up @@ -130,7 +130,7 @@ class="torrent-search--grouped__type"
@foreach ($media->torrents['Seasons'] ?? [] as $seasonName => $season)
<details
class="torrent-search--grouped__dropdown"
@if ($loop->last)
@if ($loop->first)
open
@endif
>
Expand Down Expand Up @@ -187,7 +187,7 @@ class="torrent-search--grouped__type"
@foreach ($season['Episodes'] ?? [] as $episodeName => $episode)
<details
class="torrent-search--grouped__dropdown"
@if ($loop->last && ! $season->has('Season Pack'))
@if ($loop->first && ! $season->has('Season Pack'))
open
@endif
>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/livewire/similar-torrent.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class="torrent-search--grouped__dropdown"
@foreach ($similarTorrents['Specials'] as $specialName => $special)
<details
class="torrent-search--grouped__dropdown"
@if ($checked || $loop->last)
@if ($checked || $loop->first)
open
@endif
>
Expand Down Expand Up @@ -703,7 +703,7 @@ class="similar-torrents__checkbox"
@foreach ($similarTorrents['Seasons'] ?? [] as $seasonName => $season)
<details
class="torrent-search--grouped__dropdown"
@if ($checked || $loop->last)
@if ($checked || $loop->first)
open
@endif
>
Expand Down Expand Up @@ -786,7 +786,7 @@ class="similar-torrents__checkbox"
@foreach ($season['Episodes'] ?? [] as $episodeName => $episode)
<details
class="torrent-search--grouped__dropdown"
@if ($checked || ($loop->last && ! $season->has('Season Pack')))
@if ($checked || ($loop->first && ! $season->has('Season Pack')))
open
@endif
>
Expand Down

0 comments on commit dff9f69

Please sign in to comment.