3136: Fetch actual job objects for use in rendering pipeline jobs.
[arvados.git] / apps / workbench / app / helpers / pipeline_instances_helper.rb
index 5a163c4c1a9a8c2f45fc09e5a639a7cbdc1755fe..bce713e880d08943c1a22a3fba9b196ed61cc96a 100644 (file)
@@ -22,32 +22,30 @@ module PipelineInstancesHelper
     pj
   end
 
-  def pipieline_log_history(job_uuids)
-    results = []
-
-    log_history = Log.where(event_type: 'transient-log-entry',
-                            object_uuid: job_uuids).order('id DESC').limit(20).all
-    if !log_history.results.empty?
-      reversed_results = log_history.results.reverse
-      reversed_results.each do |entry|
-        summary = entry.summary
-        results = results.concat summary.split("\n")
-      end
-    end
-
-    return results
-  end
-
   protected
 
   def pipeline_jobs_newschool object
     ret = []
     i = -1
 
+    jobuuids = object.components.select { |cname, c| c[:job] and c[:job][:uuid] }
+    job = {}
+    Job.where(uuid: jobuuids).each do |j|
+      job[j[:uuid]] = j
+    end
+
     object.components.each do |cname, c|
       i += 1
       pj = {index: i, name: cname}
-      pj[:job] = c[:job].is_a?(Hash) ? c[:job] : {}
+      if not c.is_a?(Hash)
+        ret << pj
+        next
+      end
+      if c[:job] and c[:job][:uuid]
+        pj[:job] = job[c[:job][:uuid]]
+      else
+        pj[:job] = c[:job].is_a?(Hash) ? c[:job] : {}
+      end
       pj[:percent_done] = 0
       pj[:percent_running] = 0
       if pj[:job][:success]
@@ -77,17 +75,22 @@ module PipelineInstancesHelper
       end
       if pj[:job][:success]
         pj[:result] = 'complete'
+        pj[:labeltype] = 'success'
         pj[:complete] = true
         pj[:progress] = 1.0
       elsif pj[:job][:finished_at]
         pj[:result] = 'failed'
+        pj[:labeltype] = 'danger'
         pj[:failed] = true
       elsif pj[:job][:started_at]
         pj[:result] = 'running'
+        pj[:labeltype] = 'primary'
       elsif pj[:job][:uuid]
         pj[:result] = 'queued'
+        pj[:labeltype] = 'default'
       else
         pj[:result] = 'none'
+        pj[:labeltype] = 'default'
       end
       pj[:job_id] = pj[:job][:uuid]
       pj[:script] = pj[:job][:script] || c[:script]