16663: Merge branch 'master'
[arvados.git] / apps / workbench / app / models / pipeline_instance_work_unit.rb
index 517dbc7a352a78502117c85662cc1e7318739eb8..1d75f584334ee944837183f27f6efc9f9d66c68d 100644 (file)
@@ -9,7 +9,7 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
     items = []
 
     jobs = {}
-    results = Job.where(uuid: @proxied.job_ids.values).results
+    results = Job.where(uuid: @proxied.job_ids.values).with_count("none").results
     results.each do |j|
       jobs[j.uuid] = j
     end
@@ -59,4 +59,22 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
   def template_uuid
     get(:pipeline_template_uuid)
   end
+
+  def state_label
+    if get(:state) != "Failed"
+      return super
+    end
+    if get(:components_summary).andand[:failed].andand > 0
+      return super
+    end
+    # Show "Cancelled" instead of "Failed" if there are no failed
+    # components. #12840
+    get(:components).each do |_, c|
+      jstate = c[:job][:state] rescue nil
+      if jstate == "Failed"
+        return "Failed"
+      end
+    end
+    "Cancelled"
+  end
 end