mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 13:14:03 +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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue