From 167a594f08d81ab6cf534f9f0a35c678cf5cd8b5 Mon Sep 17 00:00:00 2001 From: Vitalii Chulak Date: Mon, 12 Feb 2024 19:03:17 +0200 Subject: [PATCH] Report page: add date to hour converter Signed-off-by: Vitalii Chulak --- lib/auxiliary/time_helper.rb | 7 +++++++ lib/templates/report.html.erb | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/auxiliary/time_helper.rb b/lib/auxiliary/time_helper.rb index 61971c2b..a1d1c5a5 100644 --- a/lib/auxiliary/time_helper.rb +++ b/lib/auxiliary/time_helper.rb @@ -16,5 +16,12 @@ def seconds_to_time(sec) def time_diff(start, finish) ((finish - start) * 24 * 60 * 60).to_i end + + def days_to_hours(time_str) + days, time = time_str.split('.') + hours, minutes, seconds = time.split(':').map(&:to_i) + total_hours = days.to_i * 24 + hours + "#{format('%02d', total_hours)}:#{format('%02d', minutes)}:#{format('%02d', seconds)}" + end end end diff --git a/lib/templates/report.html.erb b/lib/templates/report.html.erb index d75f7960..ab46a9fb 100644 --- a/lib/templates/report.html.erb +++ b/lib/templates/report.html.erb @@ -61,7 +61,7 @@ <%= test['name'] %> <% unless test['url'].nil? %><% end %> - <%= test['estimatedruntime'] %> + <%= days_to_hours(test['estimatedruntime'])%> <%= test['status'] %> <% end %> @@ -74,7 +74,7 @@ <%= test['name'] %> <% unless test['url'].nil? %><% end %> - <%= test['estimatedruntime'] %> + <%= days_to_hours(test['estimatedruntime']) %> Skipped <% end %>