get_progress: cleanup case statement

This commit is contained in:
Björn Geuken 2015-04-17 10:15:38 +02:00
parent eea7d94223
commit e9ba87a49c

View file

@ -28,16 +28,17 @@ class Target < ActiveRecord::Base
# ====Returns # ====Returns
# * +String+ -> progress in percent # * +String+ -> progress in percent
def get_progress def get_progress
case unit numerator = case unit
when Target.units[:submissions] when Target.units[:submissions]
numerator = conference.events.where('created_at < ?', due_date).count conference.events.where('created_at < ?', due_date).count
when Target.units[:registrations] when Target.units[:registrations]
numerator = conference.registrations.where('created_at < ?', due_date).count conference.registrations.where('created_at < ?', due_date).count
when Target.units[:program_minutes] when Target.units[:program_minutes]
numerator = conference.current_program_minutes conference.current_program_minutes
else else
numerator = 0 0
end end
(100 * numerator / target_count).to_s (100 * numerator / target_count).to_s
end end