mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-22 07:04:09 +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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue