mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 14:11:10 +00:00
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
|
||||
def get_progress
|
||||
numerator = 0
|
||||
if unit == Target.units[:submissions]
|
||||
case unit
|
||||
when Target.units[:submissions]
|
||||
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
|
||||
elsif unit == Target.units[:program_minutes]
|
||||
when Target.units[:program_minutes]
|
||||
numerator = conference.current_program_minutes
|
||||
end
|
||||
(100 * numerator / target_count).to_s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue