2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-03-03 15:45:06 +02:00
|
|
|
module Admin
|
|
|
|
|
class ReportsController < Admin::BaseController
|
|
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
|
|
|
load_and_authorize_resource :program, through: :conference, singleton: true
|
2017-08-09 12:05:11 +03:00
|
|
|
# For some reason this doesn't work, so a workaround is used
|
|
|
|
|
# load_and_authorize_resource :event, through: :program
|
2017-03-03 15:45:06 +02:00
|
|
|
|
|
|
|
|
def index
|
2017-08-09 12:05:11 +03:00
|
|
|
@events = Event.accessible_by(current_ability).where(program: @program)
|
2017-03-03 15:45:06 +02:00
|
|
|
@events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id))
|
|
|
|
|
@events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id))
|
|
|
|
|
@events_with_requirements = @events.where.not(description: ['', nil])
|
|
|
|
|
|
|
|
|
|
attended_registrants_ids = @conference.registrations.where(attended: true).pluck(:user_id)
|
2017-04-06 23:19:58 -04:00
|
|
|
@missing_event_speakers = EventUser.joins(:event)
|
|
|
|
|
.where('event_role = ? and program_id = ?', 'submitter', @program.id)
|
|
|
|
|
.where.not(user_id: attended_registrants_ids)
|
|
|
|
|
.includes(:user, :event)
|
2017-03-03 15:45:06 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|