get_progress: Turn if condition into switch
This commit is contained in:
parent
83bf6a512d
commit
db59fa096c
1 changed files with 4 additions and 3 deletions
|
|
@ -29,11 +29,12 @@ class Target < ActiveRecord::Base
|
||||||
# * +String+ -> progress in percent
|
# * +String+ -> progress in percent
|
||||||
def get_progress
|
def get_progress
|
||||||
numerator = 0
|
numerator = 0
|
||||||
if unit == Target.units[:submissions]
|
case unit
|
||||||
|
when Target.units[:submissions]
|
||||||
numerator = conference.events.where('created_at < ?', due_date).count
|
numerator = conference.events.where('created_at < ?', due_date).count
|
||||||
elsif unit == Target.units[:registrations]
|
when Target.units[:registrations]
|
||||||
numerator = conference.registrations.where('created_at < ?', due_date).count
|
numerator = conference.registrations.where('created_at < ?', due_date).count
|
||||||
elsif unit == Target.units[:program_minutes]
|
when Target.units[:program_minutes]
|
||||||
numerator = conference.current_program_minutes
|
numerator = conference.current_program_minutes
|
||||||
end
|
end
|
||||||
(100 * numerator / target_count).to_s
|
(100 * numerator / target_count).to_s
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue