diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-03 09:25:13 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-04 08:39:06 +0200 |
commit | 5d4183e58d08a03dfc73c4bf1705aa926270052d (patch) | |
tree | 69b42d25ac19c4fbd93fc6b0a1e23728dc8b2726 /app/models/project_services/chat_message/pipeline_message.rb | |
parent | 0f976727c4325e7837a051ae98dbe4215b12f6e0 (diff) | |
download | gitlab-ce-5d4183e58d08a03dfc73c4bf1705aa926270052d.tar.gz |
Convert seconds to minutes and hours on chat notifationszj-chat-message-pretty-time
In the pipeline message, the duration of the pipeline was shown as:
> gitlab-org/gitlab-ee: Pipeline #8002259 of master branch by Douwe Maan
failed in 8612 seconds
But this many seconds only gave me a clue how long the pipeline took,
so now this will be shown as something like: 02:20:12 which gives a much
better measure of time.
Diffstat (limited to 'app/models/project_services/chat_message/pipeline_message.rb')
-rw-r--r-- | app/models/project_services/chat_message/pipeline_message.rb | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/app/models/project_services/chat_message/pipeline_message.rb b/app/models/project_services/chat_message/pipeline_message.rb index 4628d9b1a7b..47b68f00cff 100644 --- a/app/models/project_services/chat_message/pipeline_message.rb +++ b/app/models/project_services/chat_message/pipeline_message.rb @@ -15,7 +15,7 @@ module ChatMessage @ref_type = pipeline_attributes[:tag] ? 'tag' : 'branch' @ref = pipeline_attributes[:ref] @status = pipeline_attributes[:status] - @duration = pipeline_attributes[:duration] + @duration = pipeline_attributes[:duration].to_i @pipeline_id = pipeline_attributes[:id] end @@ -37,7 +37,7 @@ module ChatMessage { title: "Pipeline #{pipeline_link} of #{branch_link} #{ref_type} by #{user_name} #{humanized_status}", subtitle: "in #{project_link}", - text: "in #{duration} #{time_measure}", + text: "in #{pretty_duration(duration)}", image: user_avatar || '' } end @@ -45,7 +45,7 @@ module ChatMessage private def message - "#{project_link}: Pipeline #{pipeline_link} of #{branch_link} #{ref_type} by #{user_name} #{humanized_status} in #{duration} #{time_measure}" + "#{project_link}: Pipeline #{pipeline_link} of #{branch_link} #{ref_type} by #{user_name} #{humanized_status} in #{pretty_duration(duration)}" end def humanized_status @@ -84,9 +84,5 @@ module ChatMessage def pipeline_link "[##{pipeline_id}](#{pipeline_url})" end - - def time_measure - 'second'.pluralize(duration) - end end end |