mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 06:01:12 +00:00
Avoid float conversion when calculating progress
This commit is contained in:
parent
5043d26cc5
commit
1862534b2c
2 changed files with 4 additions and 6 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
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class Event < ActiveRecord::Base
|
|||
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 * true_items / result.length).to_s
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue