8876: when computing cpu and running times, use the work unit's start and finished...
[arvados.git] / apps / workbench / app / views / work_unit / _show_child.html.erb
index 64881a1ff0a167dfe54f8c25b7fd9e952bcf1e70..e5aacc7d78abc13794c171d1b1573c21619da56a 100644 (file)
@@ -2,7 +2,6 @@
   <div class="panel-heading">
     <div class="container-fluid">
       <div class="row-fluid">
-        <%# column offset 0 %>
         <div class="col-md-2" style="word-break:break-all;">
           <h4 class="panel-title">
             <a data-toggle="collapse" href="#collapse<%= i %>">
           </h4>
         </div>
 
-        <%# column offset 2 %>
         <div class="col-md-2 pipeline-instance-spacing">
           <%= render partial: 'work_unit/progress', locals: {wu: current_obj} %>
         </div>
 
-        <%# column offset 4 %>
         <% if not current_obj %>
           <div class="col-md-8"></div>
         <% else %>
           <div class="col-md-1">
-              <% if current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
-                <% if current_obj.log_collection %>
-                  <% logCollection = Collection.find? current_obj.log_collection %>
-                  <% if logCollection %>
-                    <%= link_to "Log", "#{current_obj.uri}#Log" %>
-                  <% else %>
-                    Log unavailable
-                  <% end %>
-                <% end %>
-              <% elsif current_obj.state_label == "Running" %>
-                <% if current_obj.readable? %>
-                  <%= link_to "Log", "#{current_obj.uri}#Log" %>
-                <% else %>
-                  Log unavailable
-                <% end %>
-              <% end %>
+            <%= current_obj.link_to_log %>
           </div>
 
-          <%# column offset 5 %>
-          <% if current_obj.state_label != "Queued" %>
+          <% walltime = current_obj.walltime %>
+          <% cputime = current_obj.cputime %>
           <div class="col-md-3">
-            <% if current_obj.started_at %>
-              <% walltime = ((if current_obj.finished_at then current_obj.finished_at else Time.now() end) - current_obj.started_at) %>
-              <% cputime = (current_obj.runtime_constraints.andand[:min_nodes] || 1) *
-                           ((current_obj.finished_at || Time.now()) - current_obj.started_at) %>
-              <%= render_runtime(walltime, false) %>
-              <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
-            <% end %>
-          </div>
+          <% if walltime and cputime %>
+            <%= render_runtime(walltime, false) %>
+            <% if cputime > 0 %> / <%= render_runtime(cputime, false) %> (<%= (cputime/walltime).round(1) %>&Cross;)<% end %>
           <% end %>
+          </div>
 
-          <% if current_obj.state_label == "Queued" %>
-            <%# column offset 5 %>
-            <div class="col-md-6">
-              <% queuetime = Time.now - Time.parse(current_obj.created_at.to_s) %>
+          <% queuetime = current_obj.queuedtime %>
+          <% if queuetime %>
+            <div class="col-md-3">
               Queued for <%= render_runtime(queuetime, false) %>.
             </div>
-          <% elsif current_obj.state_label == "Running" %>
-            <% if current_obj.child_summary %>
-              <%# column offset 8 %>
-              <div class="col-md-3">
-                <span class="task-summary-status">
-                  <% if current_obj.child_summary_str %>
-                    <%= current_obj.child_summary_str %>
-                  <% end %>
-                </span>
-              </div>
-            <% end %>
-          <% elsif current_obj.state_label.in? ["Complete", "Failed", "Cancelled"] %>
-            <%# column offset 8 %>
-            <div class="col-md-4 text-overflow-ellipsis">
+          <% elsif current_obj.show_child_summary %>
+            <div class="col-md-3">
+              <span class="task-summary-status">
+                <%= current_obj.child_summary_str %>
+              </span>
+            </div>
+          <% elsif current_obj.is_finished? %>
+            <div class="col-md-3 text-overflow-ellipsis">
               <% if current_obj.output %>
-                <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', friendly_name: true) %>
-              <% elsif current_obj.output %>
                 <%= link_to_arvados_object_if_readable(current_obj.output, 'Output data not available', link_text: "Output of #{current_obj.label}") %>
               <% else %>
                 No output.
             </div>
           <% end %>
 
-          <% if current_obj.state_label.in? ["Queued", "Running"] and current_obj.can_cancel? and @object.editable? %>
-            <%# column offset 11 %>
-            <div class="col-md-1 pipeline-instance-spacing">
+          <div class="col-md-1 pipeline-instance-spacing">
+          <% if current_obj.can_cancel? and @object.editable? %>
               <%= form_tag "#{current_obj.uri}/cancel", remote: true, style: "display:inline; padding-left: 1em" do |f| %>
                 <%= hidden_field_tag :return_to, url_for(@object) %>
                 <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-child-button"} %>
               <% end %>
-            </div>
           <% end %>
+          </div>
         <% end %>
       </div>
     </div>