Merge pull request #657 from bgeuken/calculate_progress
Calculate progress
This commit is contained in:
commit
b15c1abd2e
2 changed files with 5 additions and 8 deletions
|
|
@ -19,13 +19,11 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def event_progress_color(progress)
|
||||
progress = progress.to_i
|
||||
|
||||
case progress
|
||||
case progress.to_i
|
||||
when 100 then 'progress-bar-success'
|
||||
when 86 then 'progress-bar-info'
|
||||
when 85 then 'progress-bar-info'
|
||||
when 71 then 'progress-bar-warning'
|
||||
when 14, 29, 43, 57 then 'progress-bar-danger'
|
||||
when 14, 28, 42, 57 then 'progress-bar-danger'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -207,11 +207,10 @@ class Event < ActiveRecord::Base
|
|||
# Returns the progress of the proposal's set up
|
||||
#
|
||||
# ====Returns
|
||||
# * +Fixnum+ -> Progress in Percent
|
||||
# * +String+ -> Progress in Percent
|
||||
def calculate_progress
|
||||
result = self.progress_status
|
||||
true_items = result.select { |_key, value| value }.length
|
||||
(true_items / result.length.to_f * 100).round(0).to_s
|
||||
(100 * result.values.count(true) / result.values.count).to_s
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue