4233: ignore negative deltas when charting log stats
[arvados.git] / apps / workbench / app / controllers / jobs_controller.rb
index 841d3a9fdc6827486a7f54948e6c63ee4b3b5b1a..e6d0ccd3bde8f7e79d6d805d2d8073b3223737cb 100644 (file)
@@ -1,17 +1,28 @@
 class JobsController < ApplicationController
+  include JobsHelper
 
   def generate_provenance(jobs)
-    nodes = []
+    return if params['tab_pane'] != "Provenance"
+
+    nodes = {}
     collections = []
+    hashes = []
     jobs.each do |j|
-      nodes << j
-      collections << j[:output]
-      collections.concat(ProvenanceHelper::find_collections(j[:script_parameters]))
-      nodes << {:uuid => j[:script_version]}
+      nodes[j[:uuid]] = j
+      hashes << j[:output]
+      ProvenanceHelper::find_collections(j[:script_parameters]) do |hash, uuid|
+        collections << uuid if uuid
+        hashes << hash if hash
+      end
+      nodes[j[:script_version]] = {:uuid => j[:script_version]}
     end
 
     Collection.where(uuid: collections).each do |c|
-      nodes << c
+      nodes[c[:portable_data_hash]] = c
+    end
+
+    Collection.where(portable_data_hash: hashes).each do |c|
+      nodes[c[:portable_data_hash]] = c
     end
 
     @svg = ProvenanceHelper::create_provenance_graph nodes, "provenance_svg", {
@@ -25,6 +36,7 @@ class JobsController < ApplicationController
     if params[:uuid]
       @objects = Job.where(uuid: params[:uuid])
       generate_provenance(@objects)
+      render_index
     else
       @limit = 20
       super
@@ -33,11 +45,20 @@ class JobsController < ApplicationController
 
   def cancel
     @object.cancel
-    redirect_to @object
+    if params[:return_to]
+      redirect_to params[:return_to]
+    else
+      redirect_to @object
+    end
   end
 
   def show
     generate_provenance([@object])
+    super
+  end
+
+  def push_logs
+    @push_logs = stderr_log_records([@object.uuid])
   end
 
   def index_pane_list
@@ -49,6 +70,6 @@ class JobsController < ApplicationController
   end
 
   def show_pane_list
-    %w(Status Attributes Provenance Metadata JSON API)
+    %w(Status Log Details Provenance Advanced)
   end
 end