Merge branch 'statistics' of github.com:differentreality/osem into differentreality-statistics

This commit is contained in:
Ancor Gonzalez Sosa 2013-07-16 15:43:22 +02:00
commit 45b95584e0
4 changed files with 117 additions and 90 deletions

View file

@ -21,10 +21,21 @@ class Admin::StatsController < ApplicationController
@speaker_fields_reg = %w[with_partner need_access other_needs diet arrival departure] @speaker_fields_reg = %w[with_partner need_access other_needs diet arrival departure]
@supporter_levels = @conference.supporter_levels @supporter_levels = @conference.supporter_levels
@tickets = @conference.registrations.find_by_sql("select *
from registrations inner join supporter_registrations
ON registrations.id = supporter_registrations.registration_id
inner join supporter_levels
ON supporter_levels.id = supporter_registrations.supporter_level_id
where registrations.conference_id = #{@conference.id}")
end end
def reg_support(level) def reg_support(level)
Registration.find_by_sql("select supporter_registrations.* FROM registrations, supporter_registrations, supporter_levels WHERE registrations.id = supporter_registrations.registration_id AND registrations.conference_id = #{@conference.id} AND supporter_registrations.supporter_level_id = #{level.id}") Registration.find_by_sql("select supporter_registrations.*
FROM registrations INNER JOIN supporter_registrations
ON registrations.id = supporter_registrations.registration_id
WHERE registrations.conference_id = #{@conference.id}
AND supporter_registrations.supporter_level_id = #{level.id}")
end end
def speaker_reg(speaker) def speaker_reg(speaker)

View file

@ -1,67 +1,72 @@
%h3 .row-fluid
Registered .span12
- if @registered %h3
= "(#{@registered})" Registered
- if @attendees - if @registered
= " - Attendees (#{@attendees})" = "(#{@registered})"
%table.table.table-bordered.table-striped - if @attendees
%thead = " - Attendees (#{@attendees})"
%th General Stats .row-fluid
%th # .span3
%tr
%td Registered attended
%td= @registered_attended
%tr
%td Registered not attended
%td= @registered_not_attended
%tr
%td Attended with partner
%td= @attended_with_partner
%tr
%td Registred to attend with partner
%td= @registered_with_partner
%tr
%td Handicapped Access for:
%td= @conference.registrations.where("handicapped_access_required = ?", true).count
%tr
%td Staying at suggested hotel:
%td= @conference.registrations.where("using_affiliated_lodging = ?", true).count
- if @conference.use_dietary_choices == true
- diet_choices = []
- @conference.dietary_choices.each do |d|
- count = @conference.registrations.where("dietary_choice_id = ?", d.id).count
- if count > 0
- diet_choices << [d.title, count]
- if diet_choices.any?
%table.table.table-bordered.table-striped %table.table.table-bordered.table-striped
%thead %thead
%th Dietary Choice %th General Stats
%th # %th #
%th Percentage %tr
- diet_choices.each do |d| %td Registered attended
%tr %td= @registered_attended
%td= d[0] %tr
%td= d[1] %td Registered not attended
%td %td= @registered_not_attended
- if @registered and @registered > 0 %tr
= "#{d[1] * 100 / @registered}% of registered" %td Attended with partner
- if @attendees and @attendees > 0 %td= @attended_with_partner
%br %tr
= "#{d[1] * 100 / @attendees}% of attendees" %td Registred to attend with partner
%td= @registered_with_partner
%tr
%td Handicapped Access for
%td= @conference.registrations.where("handicapped_access_required = ?", true).count
%tr
%td Staying at suggested hotel
%td= @conference.registrations.where("using_affiliated_lodging = ?", true).count
- if @conference.social_events.count > 0 .span3
- social_events = [] - if @conference.use_dietary_choices == true
- @conference.social_events.each do |social_event| - diet_choices = []
- count = @conference.registrations.joins(:social_events).where("registrations_social_events.social_event_id = ?", social_event.id).count - @conference.dietary_choices.each do |d|
- if count > 0 - count = @conference.registrations.where("dietary_choice_id = ?", d.id).count
- social_events << [social_event.title, count] - if count > 0
- if social_events.any? - diet_choices << [d.title, count]
%table.table.table-bordered.table-striped - if diet_choices.any?
%thead %table.table.table-bordered.table-striped
%th Social Event %thead
%th # %th Dietary Choice
- social_events.each do |s| %th #
%tr %th Percentage
%td= s[0] - diet_choices.each do |d|
%td= s[1] %tr
%td= d[0]
%td= d[1]
%td
- if @registered and @registered > 0
= "#{d[1] * 100 / @registered}% of registered"
- if @attendees and @attendees > 0
%br
= "#{d[1] * 100 / @attendees}% of attendees"
.span3
- if @conference.social_events.count > 0
- social_events = []
- @conference.social_events.each do |social_event|
- count = @conference.registrations.joins(:social_events).where("registrations_social_events.social_event_id = ?", social_event.id).count
- if count > 0
- social_events << [social_event.title, count]
- if social_events.any?
%table.table.table-bordered.table-striped
%thead
%th Social Event
%th #
- social_events.each do |s|
%tr
%td= s[0]
%td= s[1]

View file

@ -1,7 +1,7 @@
- count =0 - count =0
%h3 %h3
Speakers (#{@speakers.length}) Speakers (#{@speakers.length})
%table.table.table-striped.table-bordered.table-hover#events %table.table.table-striped.table-bordered.table-hover#speakertable
%thead %thead
%th %th
ID ID
@ -33,4 +33,11 @@
- elsif field == 'arrival' || field == 'departure' - elsif field == 'arrival' || field == 'departure'
= getdatetime(reg, field) = getdatetime(reg, field)
- else - else
= reg.send(field.to_sym) = reg.send(field.to_sym)
:javascript
$(document).ready(function(){
$('#speakertable').dataTable({
"bPaginate": false
});
});

View file

@ -1,24 +1,28 @@
%h3 .row-fluid
Tickets (#{@tickets.length if @tickets}#{0 unless @tickets}) .span12
- if @supporter_levels.count > 0 %h3
%table.table.table-bordered.table-striped Non-free Tickets (#{@tickets.length if @tickets}#{0 unless @tickets})
%thead .row-fluid
%th Support Level .span5
%th # - if @supporter_levels.count > 0
%th % %table.table.table-bordered.table-striped
- @supporter_levels.each do |level| %thead
- reg_support = reg_support(level) %th Support Level
- if reg_support.count > 0 %th #
%tr %th %
%td= level.title - @supporter_levels.each do |level|
%td - reg_support = reg_support(level)
= reg_support.count - if reg_support.count > 0
%td %tr
- if @registered and @registered > 0 %td= level.title
= "#{reg_support.count * 100 / @registered}% of registered" %td
- if @attendees and @attendees > 0 = reg_support.count
%br %td
= "#{reg_support.count * 100 / @attendees}% of attendees" - if @registered and @registered > 0
- else = "#{reg_support.count * 100 / @registered}% of registered"
%p - if @attendees and @attendees > 0
No tickets sold yet %br
= "#{reg_support.count * 100 / @attendees}% of attendees"
- else
%p
No tickets sold yet