17119: Merge branch 'master' into 17119-add-filter-groups
[arvados.git] / apps / workbench / app / controllers / jobs_controller.rb
index a85a70b26896047f378cd4101043733410a970e3..e5c71cb275ed19b21b5db637d49fe7e356b64aea 100644 (file)
@@ -1,7 +1,12 @@
-class JobsController < ApplicationController
-  skip_around_filter :require_thread_api_token, only: :show
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
 
-  include JobsHelper
+class JobsController < ApplicationController
+  skip_around_action :require_thread_api_token, if: proc { |ctrl|
+    !Rails.configuration.Users.AnonymousUserToken.empty? and
+    'show' == ctrl.action_name
+  }
 
   def generate_provenance(jobs)
     return if params['tab_pane'] != "Provenance"
@@ -19,11 +24,11 @@ class JobsController < ApplicationController
       nodes[j[:script_version]] = {:uuid => j[:script_version]}
     end
 
-    Collection.where(uuid: collections).each do |c|
+    Collection.where(uuid: collections).with_count("none").each do |c|
       nodes[c[:portable_data_hash]] = c
     end
 
-    Collection.where(portable_data_hash: hashes).each do |c|
+    Collection.where(portable_data_hash: hashes).with_count("none").each do |c|
       nodes[c[:portable_data_hash]] = c
     end
 
@@ -60,14 +65,9 @@ class JobsController < ApplicationController
   end
 
   def logs
-    @logs = Log.select(%w(event_type object_uuid event_at properties))
-               .order('event_at DESC')
-               .filter([["event_type",  "=", "stderr"],
-                        ["object_uuid", "in", [@object.uuid]]])
-               .limit(500)
-               .results
-               .to_a
-               .map{ |e| e.serializable_hash.merge({ 'prepend' => true }) }
+    @logs = @object.
+      stderr_log_query(Rails.configuration.Workbench.RunningJobLogRecordsToFetch).
+      map { |e| e.serializable_hash.merge({ 'prepend' => true }) }
     respond_to do |format|
       format.json { render json: @logs }
     end
@@ -82,8 +82,6 @@ class JobsController < ApplicationController
   end
 
   def show_pane_list
-    panes = %w(Status Log Details Provenance Advanced)
-    panes.delete 'Log' if !current_user
-    panes
+    %w(Status Log Details Provenance Advanced)
   end
 end