diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-10 22:45:30 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-10 23:12:02 +0800 |
commit | 21fdc1edaecf228c1fdc540375bbdad0fd69164a (patch) | |
tree | 8da76adcca752e497daa559ca7667787d20c3003 /app/helpers/time_helper.rb | |
parent | 831b6c8fda1adec32c0719500ad3e830284fb2af (diff) | |
download | gitlab-ce-21fdc1edaecf228c1fdc540375bbdad0fd69164a.tar.gz |
Cleanup the use of duration and optimize some queries
Diffstat (limited to 'app/helpers/time_helper.rb')
-rw-r--r-- | app/helpers/time_helper.rb | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb index a031abb8676..271e839692a 100644 --- a/app/helpers/time_helper.rb +++ b/app/helpers/time_helper.rb @@ -15,25 +15,9 @@ module TimeHelper "#{from.to_s(:short)} - #{to.to_s(:short)}" end - def duration_in_numbers(finished_at, started_at) - interval = interval_in_seconds(started_at, finished_at) + def duration_in_numbers(duration) + time_format = duration < 1.hour ? "%M:%S" : "%H:%M:%S" - duration_in_numbers_from_interval(interval) - end - - def duration_in_numbers_from_interval(interval) - time_format = interval < 1.hour ? "%M:%S" : "%H:%M:%S" - - Time.at(interval).utc.strftime(time_format) - end - - private - - def interval_in_seconds(started_at, finished_at = nil) - if started_at && finished_at - finished_at.to_i - started_at.to_i - elsif started_at - Time.now.to_i - started_at.to_i - end + Time.at(duration).utc.strftime(time_format) end end |