mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-28 10:04:07 +01:00
Move calculation out of view
This commit is contained in:
parent
27ba50b460
commit
03282638af
3 changed files with 22 additions and 8 deletions
|
|
@ -9,15 +9,15 @@ module Stats
|
|||
end
|
||||
|
||||
def avg
|
||||
@avg ||= (sum / count) / SECONDS_PER_DAY
|
||||
@avg ||= to_days(sum / count)
|
||||
end
|
||||
|
||||
def max
|
||||
@max ||= max_in_seconds / SECONDS_PER_DAY
|
||||
@max ||= to_days(max_in_seconds)
|
||||
end
|
||||
|
||||
def min
|
||||
@min ||= min_in_seconds / SECONDS_PER_DAY
|
||||
@min ||= to_days(min_in_seconds)
|
||||
end
|
||||
|
||||
def min_sec
|
||||
|
|
@ -29,6 +29,10 @@ module Stats
|
|||
|
||||
private
|
||||
|
||||
def to_days(value)
|
||||
(value * 10 / SECONDS_PER_DAY).round / 10.0
|
||||
end
|
||||
|
||||
def min_in_seconds
|
||||
@min_in_seconds ||= durations.min || 0
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<p><%= t('stats.actions_avg_completion_time', :count => (ttc.avg*10).round/10.0) %>
|
||||
<%= t('stats.actions_min_max_completion_days', :max => (ttc.max*10).round/10.0, :min => (ttc.min*10).round/10.0) %>
|
||||
<p><%= t('stats.actions_avg_completion_time', :count => ttc.avg) %>
|
||||
<%= t('stats.actions_min_max_completion_days', :max => ttc.max, :min => ttc.min) %>
|
||||
<%= t('stats.actions_min_completion_time', :time => ttc.min_sec) %></p>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue