Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-10 17:45:30 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-08-10 18:12:02 +0300
commit21fdc1edaecf228c1fdc540375bbdad0fd69164a (patch)
tree8da76adcca752e497daa559ca7667787d20c3003 /app/helpers/time_helper.rb
parent831b6c8fda1adec32c0719500ad3e830284fb2af (diff)
Cleanup the use of duration and optimize some queries
Diffstat (limited to 'app/helpers/time_helper.rb')
-rw-r--r--app/helpers/time_helper.rb22
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