File tree Expand file tree Collapse file tree 1 file changed +29
-4
lines changed
Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -3,16 +3,41 @@ def index
33 djs = @current_radio . djs
44 . includes ( show_series_hosts : [ :show_series ] ) . where ( enabled : true )
55 @dj = djs . find ( params [ :dj_id ] )
6- show_series = ShowSeries . joins ( "inner join show_series_hosts on show_series_hosts.user_id = #{ @dj . id } and show_series_hosts.show_series_id = show_series.id" )
6+
7+ hosted_series_ids = ShowSeries
8+ . joins ( :show_series_hosts )
9+ . where ( show_series_hosts : { user_id : @dj . id } )
10+ . pluck ( :id )
11+
12+ # need to also check GuestFruits
13+ guest_fruits_series_id = ShowSeries
14+ . where ( title : "GuestFruits" )
15+ . pick ( :id )
16+
17+ guest_show_ids =
18+ if guest_fruits_series_id
19+ ScheduledShow
20+ . joins ( :show_series )
21+ . where (
22+ dj_id : @dj . id ,
23+ show_series_id : guest_fruits_series_id
24+ )
25+ . pluck ( :id )
26+ else
27+ [ ]
28+ end
29+
730 shows = @current_radio . scheduled_shows
831 . includes ( [ :tracks ] )
9- . where ( show_series_id : show_series . pluck ( :id ) )
32+ . where (
33+ "show_series_id IN (?) OR scheduled_shows.id IN (?)" ,
34+ hosted_series_ids ,
35+ guest_show_ids
36+ )
1037 . where ( status : :archive_published )
1138 . order ( "start_at DESC" )
1239 shows = shows . page ( params [ :page ] )
1340
14- # meta = { page: params[:page], total_pages: shows.total_pages.to_i }
15- # render json: shows, meta: meta
1641 options = { }
1742 options [ :meta ] = { page : params [ :page ] , total_pages : shows . total_pages . to_i }
1843 options [ :include ] = [ 'tracks' ]
You can’t perform that action at this time.
0 commit comments