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
|
before_filter :verify_organizer
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@registrations = @conference.registrations.all(:joins => :person,
|
@registrations = @conference.registrations.includes(:person).order("registrations.created_at ASC")
|
||||||
: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")
|
|
||||||
|
|
||||||
@attendees = @conference.registrations.where("attended = ?", true).count
|
@attendees = @conference.registrations.where("attended = ?", true).count
|
||||||
@registered = @conference.registrations.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]
|
@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 *
|
@tickets = @conference.registrations.joins(:supporter_registration => :supporter_level)
|
||||||
from registrations inner join supporter_registrations
|
@tickets = @tickets.where("registrations.conference_id" => @conference).count
|
||||||
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}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def speaker_reg(speaker)
|
def speaker_reg(speaker)
|
||||||
|
|
@ -48,5 +29,4 @@ class Admin::StatsController < ApplicationController
|
||||||
|
|
||||||
helper_method :speaker_reg
|
helper_method :speaker_reg
|
||||||
helper_method :speaker_diet
|
helper_method :speaker_diet
|
||||||
helper_method :reg_support
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.row-fluid
|
.row-fluid
|
||||||
.span12
|
.span12
|
||||||
%h3
|
%h3
|
||||||
Non-free Tickets (#{@tickets.length if @tickets}#{0 unless @tickets})
|
Non-free Tickets (#{@tickets})
|
||||||
.row-fluid
|
.row-fluid
|
||||||
.span5
|
.span5
|
||||||
- if @supporter_levels.count > 0
|
- if @supporter_levels.count > 0
|
||||||
|
|
@ -11,18 +11,18 @@
|
||||||
%th #
|
%th #
|
||||||
%th %
|
%th %
|
||||||
- @supporter_levels.each do |level|
|
- @supporter_levels.each do |level|
|
||||||
- reg_support = reg_support(level)
|
- reg_count = level.supporter_registrations.count
|
||||||
- if reg_support.count > 0
|
- if reg_count > 0
|
||||||
%tr
|
%tr
|
||||||
%td= level.title
|
%td= level.title
|
||||||
%td
|
%td
|
||||||
= reg_support.count
|
= reg_count
|
||||||
%td
|
%td
|
||||||
- if @registered and @registered > 0
|
- if @registered and @registered > 0
|
||||||
= "#{reg_support.count * 100 / @registered}% of registered"
|
= "#{reg_count * 100 / @registered}% of registered"
|
||||||
- if @attendees and @attendees > 0
|
- if @attendees and @attendees > 0
|
||||||
%br
|
%br
|
||||||
= "#{reg_support.count * 100 / @attendees}% of attendees"
|
= "#{reg_count * 100 / @attendees}% of attendees"
|
||||||
- else
|
- else
|
||||||
%p
|
%p
|
||||||
No tickets sold yet
|
No tickets sold yet
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue