Merge pull request #636 from bgeuken/cleanup_get_progress
Cleanup get progress
This commit is contained in:
commit
206c3a8144
1 changed files with 13 additions and 9 deletions
|
|
@ -28,15 +28,19 @@ class Target < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +String+ -> progress in percent
|
# * +String+ -> progress in percent
|
||||||
def get_progress
|
def get_progress
|
||||||
numerator = 0
|
numerator =
|
||||||
if unit == Target.units[:submissions]
|
case unit
|
||||||
numerator = conference.events.where('created_at < ?', due_date).count
|
when Target.units[:submissions]
|
||||||
elsif unit == Target.units[:registrations]
|
conference.events.where('created_at < ?', due_date).count
|
||||||
numerator = conference.registrations.where('created_at < ?', due_date).count
|
when Target.units[:registrations]
|
||||||
elsif unit == Target.units[:program_minutes]
|
conference.registrations.where('created_at < ?', due_date).count
|
||||||
numerator = conference.current_program_minutes
|
when Target.units[:program_minutes]
|
||||||
end
|
conference.current_program_minutes
|
||||||
(numerator / target_count.to_f * 100).round(0).to_s
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
(100 * numerator / target_count).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue