Statistics on top of Events#index

This commit is contained in:
Ana
2016-06-11 14:09:23 +02:00
parent f5e52e3855
commit f5701f2e77
3 changed files with 24 additions and 0 deletions

View File

@@ -21,6 +21,9 @@ module Admin
@difficulty_levels = @program.difficulty_levels
@machine_states = @events.state_machine.states.map
@event_types = @program.event_types
@tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed)
@event_distribution = @conference.event_distribution
@scheduled_event_distribution = @conference.scheduled_event_distribution
@mystates = []
@mytypes = []

View File

@@ -316,6 +316,20 @@ class Conference < ActiveRecord::Base
Conference.calculate_event_distribution_hash(program.events.select(:state).group(:state).count)
end
##
# Returns a hash with scheduled vs unscheduled events
# { "Scheduled" => { value: number of confirmed and scheduled events, color: color },
# "Unscheduled" => { value: number of confirmed and unscheduled events, color: color }
#
# ====Returns
# * +hash+ -> hash
def scheduled_event_distribution
confirmed_events = program.events.where(state: 'confirmed')
scheduled_value = { 'value' => confirmed_events.where('start_time IS NOT NULL').count, 'color' => 'green' }
unscheduled_value = { 'value' => confirmed_events.where('start_time IS NULL').count, 'color' => 'red' }
{ 'Scheduled' => scheduled_value, 'Unscheduled' => unscheduled_value }
end
##
# Returns a hash with user distribution => {value: count of user state, color: color}
# active: signed in during the last 3 months

View File

@@ -8,6 +8,13 @@
%p.text-muted
All the submissions of your speakers
.row
.col-md-4
= render partial: 'admin/conference/doughnut_chart', locals: {title: 'Events state', data: @event_distribution}
.col-md-4
= render partial: 'admin/conference/doughnut_chart', locals: {title: 'Confirmed events scheduled', data: @scheduled_event_distribution}
.col-md-4
= render partial: 'admin/conference/doughnut_chart', locals: {title: 'Tracks of confirmed events', data: @tracks_distribution_confirmed}
.row{ style: "margin-top: 40px;"}
.col-md-12
%table.table.table-striped.table-bordered.table-hover.datatable
%thead