mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add admin stats page
This commit is contained in:
parent
8286c8130d
commit
a71a16922c
7 changed files with 240 additions and 0 deletions
58
app/controllers/admin/stats_controller.rb
Normal file
58
app/controllers/admin/stats_controller.rb
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
class Admin::StatsController < ApplicationController
|
||||
before_filter :verify_organizer
|
||||
|
||||
def index
|
||||
@registrations = @conference.registrations.all(:joins => :person,
|
||||
:order => "registrations.created_at ASC",
|
||||
:select => "registrations.*,
|
||||
people.last_name AS last_name,
|
||||
people.first_name AS first_name,
|
||||
people.public_name AS public_name,
|
||||
people.email AS email")
|
||||
|
||||
@pre_registered = @conference.registrations.where("onsite = ?", false).count
|
||||
|
||||
@registered_attended = @conference.registrations.where("attended = ? AND onsite = ?", true, false).count
|
||||
@registered_onsite = @conference.registrations.where("onsite LIKE ?", true).count
|
||||
@registered_not_attended = @conference.registrations.where("attended LIKE ? AND onsite LIKE ?", false, false).count
|
||||
|
||||
@attendees = @conference.registrations.where("attended = ?", true).count
|
||||
|
||||
@registered_with_partner = @conference.registrations.where("attending_with_partner = ?", true).count
|
||||
@attended_with_partner = @conference.registrations.where("attending_with_partner = ? AND attended = ?", true, true).count
|
||||
|
||||
@headers = %w[attended name email social_events with_partner need_access other_needs arrival departure onsite]
|
||||
|
||||
@events = @conference.events
|
||||
@tracks = @conference.tracks
|
||||
@event_states = @events.state_machine.states.map
|
||||
@speakers = Person.joins(:events).where("events.conference_id = ? AND events.state LIKE ?", @conference.id, 'confirmed').uniq
|
||||
@speaker_fields_person = %w[name email affiliation]
|
||||
@speaker_fields_reg = %w[with_partner need_access other_needs diet arrival departure]
|
||||
|
||||
@supporter_levels = @conference.supporter_levels
|
||||
|
||||
@supporter_tickets = "t"
|
||||
@professional_tickets = "t"
|
||||
|
||||
end
|
||||
|
||||
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}")
|
||||
|
||||
|
||||
end
|
||||
|
||||
def speaker_reg(speaker)
|
||||
speaker.registrations.where("conference_id = ? AND person_id = ?", @conference.id, speaker.id).first
|
||||
end
|
||||
|
||||
def speaker_diet(reg)
|
||||
@conference.dietary_choices.find(reg.dietary_choice_id)
|
||||
end
|
||||
|
||||
helper_method :speaker_reg
|
||||
helper_method :speaker_diet
|
||||
helper_method :reg_support
|
||||
|
||||
end
|
||||
|
|
@ -1,4 +1,19 @@
|
|||
module ApplicationHelper
|
||||
def getdatetime(registration, field)
|
||||
if registration.send(field.to_sym).kind_of?(String)
|
||||
DateTime.parse(registration.send(field.to_sym)).strftime("%d %b %H:%M") if registration.send(field.to_sym)
|
||||
else
|
||||
registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym)
|
||||
end
|
||||
end
|
||||
|
||||
def getdate(var)
|
||||
if var.kind_of?(String)
|
||||
DateTime.parse(var).strftime("%a, %d %b")
|
||||
else
|
||||
var.strftime("%a, %d %b")
|
||||
end
|
||||
end
|
||||
|
||||
def add_association_link(association_name, form_builder, div_class, html_options = {})
|
||||
link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(:class => "assoc btn btn-success")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class Person < ActiveRecord::Base
|
|||
:styles => {:tiny => "16x16>", :small => "32x32>", :large => "128x128>"},
|
||||
:default_url => "person_:style.png"
|
||||
validates_attachment_content_type :avatar, :content_type => [/jpg/, /jpeg/, /png/, /gif/]
|
||||
|
||||
alias_attribute :affiliation, :company
|
||||
|
||||
def to_s
|
||||
if self.public_name.empty?
|
||||
self.first_name + " " + self.last_name
|
||||
|
|
|
|||
|
|
@ -13,4 +13,9 @@ class Registration < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :person
|
||||
accepts_nested_attributes_for :supporter_registration
|
||||
accepts_nested_attributes_for :social_events
|
||||
|
||||
alias_attribute :with_partner, :attending_with_partner
|
||||
alias_attribute :social_events, :attending_social_events
|
||||
alias_attribute :need_access, :handicapped_access_required
|
||||
alias_attribute :other_needs, :other_special_needs
|
||||
end
|
||||
148
app/views/admin/stats/index.html.haml
Normal file
148
app/views/admin/stats/index.html.haml
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
.row-fluid
|
||||
.span12
|
||||
.pull-left{:style=>"margin-top:20px; margin-bottom:20px;"}
|
||||
= link_to "Registration Stats", "#", :id => "registrations-stats-link", :class => "btn btn-success"
|
||||
= link_to "Speakers Stats", "#", :id => "speakers-stats-link", :class => "btn btn-success"
|
||||
= link_to "Tickets Stats", "#", :id => "tickets-stats-link", :class => "btn btn-success"
|
||||
|
||||
#tickets-stats
|
||||
.row-fluid
|
||||
.span3
|
||||
- if @supporter_levels.count > 0
|
||||
%table.table.table-bordered.table-striped
|
||||
%thead
|
||||
%th Support Level
|
||||
%th #
|
||||
- @supporter_levels.each do |level|
|
||||
- reg_support = reg_support(level)
|
||||
- if reg_support.count > 0
|
||||
%tr
|
||||
%td= level.title
|
||||
%td= "#{reg_support.count} (#{reg_support.count * 100 / @attendees}%)"
|
||||
|
||||
|
||||
#registrations-stats
|
||||
%h3
|
||||
Pre Registered
|
||||
= "(#{@pre_registered}) -"
|
||||
OnsiteRegistrations (#{@registered_onsite}) - Attendees (#{@attendees})
|
||||
.row-fluid
|
||||
.span3
|
||||
%table.table.table-bordered.table-striped
|
||||
%thead
|
||||
%th General Stats
|
||||
%th #
|
||||
%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?
|
||||
.span3
|
||||
%table.table.table-bordered.table-striped
|
||||
%thead
|
||||
%th Dietary Choice
|
||||
%th #
|
||||
%th Percentage
|
||||
- diet_choices.each do |d|
|
||||
%tr
|
||||
%td= d[0]
|
||||
%td= d[1]
|
||||
%td
|
||||
= "#{d[1] * 100 / @pre_registered}% of registered"
|
||||
- if @attendees
|
||||
%br
|
||||
= "#{d[1] * 100 / @attendees}% of attendees"
|
||||
|
||||
- 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?
|
||||
.span3
|
||||
%table.table.table-bordered.table-striped
|
||||
%thead
|
||||
%th Social Event
|
||||
%th #
|
||||
- social_events.each do |s|
|
||||
%tr
|
||||
%td= s[0]
|
||||
%td= s[1]
|
||||
|
||||
#speakers-stats
|
||||
- count =0
|
||||
.row-fluid
|
||||
%h3
|
||||
Speakers (#{@speakers.length})
|
||||
%br
|
||||
|
||||
%table.table.table-striped.table-bordered.table-hover#events
|
||||
%thead
|
||||
%th
|
||||
ID
|
||||
- (@speaker_fields_person + @speaker_fields_reg).each do |field|
|
||||
%th
|
||||
= field.capitalize
|
||||
|
||||
- @speakers.each do |speaker|
|
||||
%tr
|
||||
%td
|
||||
= count +=1
|
||||
|
||||
- @speaker_fields_person.each do |field|
|
||||
%td
|
||||
- if field == 'name'
|
||||
= speaker.id
|
||||
= speaker.first_name
|
||||
= speaker.last_name
|
||||
%br
|
||||
(#{speaker.public_name})
|
||||
- else
|
||||
= speaker.send(field.to_sym)
|
||||
- @speaker_fields_reg.each do |field|
|
||||
%td
|
||||
- reg = speaker_reg(speaker)
|
||||
- if !reg.nil?
|
||||
- if field == "diet"
|
||||
- if reg.dietary_choice_id
|
||||
= speaker_diet(reg).title
|
||||
%br
|
||||
= reg.other_dietary_choice
|
||||
- elsif field == 'arrival' || field == 'departure'
|
||||
= getdatetime(reg, field)
|
||||
- else
|
||||
= reg.send(field.to_sym)
|
||||
|
||||
:javascript
|
||||
$("#registrations-stats-link").click(function() {
|
||||
$("#registrations-stats").toggle();
|
||||
});
|
||||
$("#speakers-stats-link").click(function() {
|
||||
$("#speakers-stats").toggle();
|
||||
});
|
||||
$("#tickets-stats-link").click(function() {
|
||||
$("#tickets-stats").toggle();
|
||||
});
|
||||
});
|
||||
|
|
@ -53,6 +53,16 @@
|
|||
= link_to(admin_conference_events_path(@conference.short_title)) do
|
||||
%i.icon-comment
|
||||
Events
|
||||
- if current_page?(admin_conference_stats_path(@conference.short_title))
|
||||
%li.active
|
||||
= link_to('#') do
|
||||
%i.icon-comment
|
||||
Stats
|
||||
- else
|
||||
%li
|
||||
= link_to(admin_conference_stats_path(@conference.short_title)) do
|
||||
%i.icon-comment
|
||||
Stats
|
||||
%li
|
||||
= link_to(admin_conference_schedule_path(@conference.short_title), :target => "_blank") do
|
||||
%i.icon-tasks
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Osem::Application.routes.draw do
|
|||
resources :conference do
|
||||
get "/schedule" => "schedule#show"
|
||||
put "/schedule" => "schedule#update"
|
||||
get "/stats" => "stats#index"
|
||||
get "/registrations" => "registrations#show"
|
||||
get "/emailsettings" => "emails#show", :as => "email_settings"
|
||||
put "/emailsettings" => "emails#update", :as => "email_settings"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue