Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report page: add date to hour converter #299

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/auxiliary/time_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@
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

Check warning

Code scanning / Rubocop

Checks for expressions containing multiple binary operations with ambiguous precedence. Warning

Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
"#{format('%02d', total_hours)}:#{format('%02d', minutes)}:#{format('%02d', seconds)}"
end
end
end
4 changes: 2 additions & 2 deletions lib/templates/report.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<%= test['name'] %>
<% unless test['url'].nil? %></a><% end %>
</td>
<td><%= test['estimatedruntime'] %></td>
<td><%= days_to_hours(test['estimatedruntime'])%></td>
<td><%= test['status'] %></td>
</tr>
<% end %>
Expand All @@ -74,7 +74,7 @@
<%= test['name'] %>
<% unless test['url'].nil? %></a><% end %>
</td>
<td><%= test['estimatedruntime'] %></td>
<td><%= days_to_hours(test['estimatedruntime']) %></td>
<td>Skipped</td>
</tr>
<% end %>
Expand Down
Loading