commit
5d5ad9348c
8 changed files with 300 additions and 195 deletions
|
|
@ -95,7 +95,7 @@ Metrics/BlockNesting:
|
||||||
Max: 4
|
Max: 4
|
||||||
|
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Max: 550
|
Max: 560
|
||||||
|
|
||||||
# avoid redundunt curly braces when it is obvious that hash is used
|
# avoid redundunt curly braces when it is obvious that hash is used
|
||||||
Style/BracesAroundHashParameters:
|
Style/BracesAroundHashParameters:
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,7 @@
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0px 10px 0px 0px;
|
padding: 0px 10px 0px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.margin-event-table{
|
||||||
|
margin-top: 40px !important;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ module Admin
|
||||||
@difficulty_levels = @program.difficulty_levels
|
@difficulty_levels = @program.difficulty_levels
|
||||||
@machine_states = @events.state_machine.states.map
|
@machine_states = @events.state_machine.states.map
|
||||||
@event_types = @program.event_types
|
@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 = []
|
@mystates = []
|
||||||
@mytypes = []
|
@mytypes = []
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ module Admin
|
||||||
@pdf_filename = "#{@conference.title}.pdf"
|
@pdf_filename = "#{@conference.title}.pdf"
|
||||||
@registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC')
|
@registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC')
|
||||||
@attended = @conference.registrations.where('attended = ?', true).count
|
@attended = @conference.registrations.where('attended = ?', true).count
|
||||||
|
|
||||||
|
@registration_distribution = @conference.registration_distribution
|
||||||
|
@affiliation_distribution = @conference.affiliation_distribution
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit; end
|
def edit; end
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,67 @@ class Conference < ActiveRecord::Base
|
||||||
Conference.calculate_event_distribution_hash(program.events.select(:state).group(:state).count)
|
Conference.calculate_event_distribution_hash(program.events.select(:state).group(:state).count)
|
||||||
end
|
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.not(start_time: nil).count, 'color' => 'green' }
|
||||||
|
unscheduled_value = { 'value' => confirmed_events.where(start_time: nil).count, 'color' => 'red' }
|
||||||
|
{ 'Scheduled' => scheduled_value, 'Unscheduled' => unscheduled_value }
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a hash with Registration attended vs. Registration not attended
|
||||||
|
# { "Attended" => { value: number of registration attended, color: color },
|
||||||
|
# "Not attended" => { value: number of registration not attended, color: color }
|
||||||
|
#
|
||||||
|
# ====Returns
|
||||||
|
# * +hash+ -> hash
|
||||||
|
def registration_distribution
|
||||||
|
reg = registrations.includes(:user)
|
||||||
|
attended_value = { 'value' => reg.where(attended: true).count, 'color' => 'magenta' }
|
||||||
|
not_attended_value = { 'value' => reg.where.not(attended: true).count, 'color' => 'blue' }
|
||||||
|
{ 'Attended' => attended_value, 'Not attended' => not_attended_value }
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a hash with affiliation =>
|
||||||
|
# {value: count of registration whose user has that affilation, color: color}
|
||||||
|
# In case that the affiliation is blank, it groups them in None and
|
||||||
|
# if the number of persons that have an affiliation are less than the 2% of
|
||||||
|
# the total number of registered people, they are grouped in others.
|
||||||
|
#
|
||||||
|
# ====Returns
|
||||||
|
# * +hash+ -> hash
|
||||||
|
def affiliation_distribution
|
||||||
|
counted_affiliations = registrations.joins(:user).group(:affiliation).count
|
||||||
|
result = {}
|
||||||
|
i=1
|
||||||
|
others = 0
|
||||||
|
none = 0
|
||||||
|
counted_affiliations.each do |key, value|
|
||||||
|
if value < 0.02 * registrations.length
|
||||||
|
others += value
|
||||||
|
elsif key.blank?
|
||||||
|
none += value
|
||||||
|
else
|
||||||
|
result[key.capitalize] = { 'value' => value, 'color' => next_color(i) }
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if others > 0
|
||||||
|
result['Others'] = { 'value' => others, 'color' => next_color(i) }
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
result['None'] = { 'value' => none, 'color' => next_color(i) } if none > 0
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns a hash with user distribution => {value: count of user state, color: color}
|
# Returns a hash with user distribution => {value: count of user state, color: color}
|
||||||
# active: signed in during the last 3 months
|
# active: signed in during the last 3 months
|
||||||
|
|
@ -536,6 +597,20 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Returns a different html colour for every i and consecutive colors are
|
||||||
|
# clearly different.
|
||||||
|
def next_color(i)
|
||||||
|
'#' + next_color_component(:r, i) + next_color_component(:g, i) + next_color_component(:b, i)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Auxiliar function which is used in next_color and returns each component of
|
||||||
|
# the color. We make use of big prime numbers to avoid repetition and to make
|
||||||
|
# consecutive colors clearly different.
|
||||||
|
def next_color_component(component, i)
|
||||||
|
big_prime_numbers = {r: 113, g: 67, b: 151}
|
||||||
|
((i*big_prime_numbers[component])%239 + 16).to_s(16)
|
||||||
|
end
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
self.create_contact
|
self.create_contact
|
||||||
self.create_program
|
self.create_program
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,16 @@
|
||||||
= "(#{@events.length})"
|
= "(#{@events.length})"
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
All the submissions of your speakers
|
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
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
%div.margin-event-table
|
||||||
%table.table.table-striped.table-bordered.table-hover.datatable
|
%table.table.table-striped.table-bordered.table-hover.datatable
|
||||||
%thead
|
%thead
|
||||||
%th
|
%th
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,14 @@
|
||||||
= link_to 'Export XLS', {format: :xlsx}, class: 'btn btn-success'
|
= link_to 'Export XLS', {format: :xlsx}, class: 'btn btn-success'
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
All the people who registered to your event
|
All the people who registered to your event
|
||||||
|
.col-md-4
|
||||||
|
= render partial: 'admin/conference/doughnut_chart', locals: {title: 'Affiliation', data: @affiliation_distribution}
|
||||||
|
- unless @conference.pending?
|
||||||
|
.col-md-4
|
||||||
|
= render partial: 'admin/conference/doughnut_chart', locals: {title: 'Attended registrations', data: @registration_distribution}
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%div.margin-event-table
|
||||||
%table.table.table-hover.datatable#registrations
|
%table.table.table-hover.datatable#registrations
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
|
|
|
||||||
|
|
@ -343,6 +343,10 @@ ActiveRecord::Schema.define(version: 20160624151257) do
|
||||||
t.boolean "include_registrations"
|
t.boolean "include_registrations"
|
||||||
t.boolean "include_sponsors"
|
t.boolean "include_sponsors"
|
||||||
t.boolean "include_lodgings"
|
t.boolean "include_lodgings"
|
||||||
|
t.string "banner_photo_file_name"
|
||||||
|
t.string "banner_photo_content_type"
|
||||||
|
t.integer "banner_photo_file_size"
|
||||||
|
t.datetime "banner_photo_updated_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.boolean "include_cfp", default: false
|
t.boolean "include_cfp", default: false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue