mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Getting rid of plain sql in stats_controller
This commit is contained in:
parent
26236424cc
commit
7e930d8d40
2 changed files with 10 additions and 30 deletions
|
|
@ -2,13 +2,7 @@ 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")
|
||||
@registrations = @conference.registrations.includes(:person).order("registrations.created_at ASC")
|
||||
|
||||
@attendees = @conference.registrations.where("attended = ?", true).count
|
||||
@registered = @conference.registrations.count
|
||||
|
|
@ -21,21 +15,8 @@ class Admin::StatsController < ApplicationController
|
|||
@speaker_fields_reg = %w[with_partner need_access other_needs diet arrival departure]
|
||||
|
||||
@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
|
||||
|
||||
def reg_support(level)
|
||||
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}")
|
||||
@tickets = @conference.registrations.joins(:supporter_registration => :supporter_level)
|
||||
@tickets = @tickets.where("registrations.conference_id" => @conference).count
|
||||
end
|
||||
|
||||
def speaker_reg(speaker)
|
||||
|
|
@ -48,5 +29,4 @@ class Admin::StatsController < ApplicationController
|
|||
|
||||
helper_method :speaker_reg
|
||||
helper_method :speaker_diet
|
||||
helper_method :reg_support
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.row-fluid
|
||||
.span12
|
||||
%h3
|
||||
Non-free Tickets (#{@tickets.length if @tickets}#{0 unless @tickets})
|
||||
Non-free Tickets (#{@tickets})
|
||||
.row-fluid
|
||||
.span5
|
||||
- if @supporter_levels.count > 0
|
||||
|
|
@ -11,18 +11,18 @@
|
|||
%th #
|
||||
%th %
|
||||
- @supporter_levels.each do |level|
|
||||
- reg_support = reg_support(level)
|
||||
- if reg_support.count > 0
|
||||
- reg_count = level.supporter_registrations.count
|
||||
- if reg_count > 0
|
||||
%tr
|
||||
%td= level.title
|
||||
%td
|
||||
= reg_support.count
|
||||
= reg_count
|
||||
%td
|
||||
- if @registered and @registered > 0
|
||||
= "#{reg_support.count * 100 / @registered}% of registered"
|
||||
= "#{reg_count * 100 / @registered}% of registered"
|
||||
- if @attendees and @attendees > 0
|
||||
%br
|
||||
= "#{reg_support.count * 100 / @attendees}% of attendees"
|
||||
= "#{reg_count * 100 / @attendees}% of attendees"
|
||||
- else
|
||||
%p
|
||||
No tickets sold yet
|
||||
Loading…
Add table
Add a link
Reference in a new issue