22 menu priority : 4
33
44 config . batch_actions = false
5- config . sort_order = "name_asc "
5+ config . sort_order = "first_submitted_at_desc "
66
77 actions :index
88
99 controller do
1010 before_action :set_default_event_filter , only : :index
1111
1212 def scoped_collection
13- Participant . joins ( :presentations ) . includes ( presentations : :session ) . distinct
13+ Participant . joins ( :presentations )
14+ . includes ( presentations : :session )
15+ . select ( "participants.*, MIN(presentations.created_at) AS first_submitted_at" )
16+ . group ( "participants.id" )
1417 end
1518
1619 def selected_event_id
@@ -38,7 +41,11 @@ def set_default_event_filter
3841 presenter_ids = sessions . joins ( :presentations )
3942 . pluck ( "presentations.participant_id" )
4043 . uniq
41- presenters = Participant . where ( id : presenter_ids ) . order ( :name )
44+ presenters = Participant . where ( id : presenter_ids )
45+ . joins ( :presentations )
46+ . merge ( Presentation . where ( session_id : sessions . select ( :id ) ) )
47+ . group ( "participants.id" )
48+ . order ( Arel . sql ( "MIN(presentations.created_at) DESC" ) )
4249
4350 render body : presenters . map { |p | "\" #{ p . name } \" <#{ p . email } >" } . join ( ",\n " ) ,
4451 content_type : Mime [ :text ]
@@ -61,5 +68,8 @@ def set_default_event_filter
6168 link_to ( p . session . title , admin_session_path ( p . session ) )
6269 end . join ( ", " ) . html_safe
6370 end
71+ column ( "Submitted At" , sortable : :first_submitted_at ) do |presenter |
72+ presenter . first_submitted_at &.strftime ( "%-m/%-d/%y" )
73+ end
6474 end
6575end
0 commit comments