fix: sort episodic podcasts by season

This commit is contained in:
Benjamin Bellamy 2020-09-11 22:53:38 +02:00 committed by Yassine Doghri
parent 2379826352
commit d7b6794f68
1 changed files with 6 additions and 2 deletions

View File

@ -270,7 +270,7 @@ class EpisodeModel extends Model
$sortNumberField =
$podcastType == 'serial'
? 'if(isnull(season_number),0,season_number)*1000+number'
: 'published_at';
: 'if(isnull(season_number),0,season_number)*100000000000000+published_at';
$sortNumberValue =
$podcastType == 'serial'
? (empty($episode->season_number)
@ -278,7 +278,11 @@ class EpisodeModel extends Model
: $episode->season_number) *
1000 +
$episode->number
: $episode->published_at;
: (empty($episode->season_number)
? 0
: $episode->season_number) *
100000000000000 +
date('YmdHis', strtotime($episode->published_at));
$previousData = $this->orderBy('(' . $sortNumberField . ') DESC')
->where([