refs #10078
[arvados.git] / apps / workbench / app / controllers / application_controller.rb
index 10c33c3f0af801520c6659aed2aade5d1e53cba7..5b3f3f59ecebaf1c3b93efbe06509804e3dfa9f1 100644 (file)
@@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base
 
   ERROR_ACTIONS = [:render_error, :render_not_found]
 
+  prepend_before_filter :set_current_request_id, except: ERROR_ACTIONS
   around_filter :thread_clear
   around_filter :set_thread_api_token
   # Methods that don't require login should
@@ -768,7 +769,7 @@ class ApplicationController < ActionController::Base
 
   helper_method :user_notifications
   def user_notifications
-    return [] if @errors or not current_user.andand.is_active
+    return [] if @errors or not current_user.andand.is_active or not Rails.configuration.show_user_notifications_in_dashboard
     @notifications ||= @@notification_tests.map do |t|
       t.call(self, current_user)
     end.compact
@@ -854,7 +855,8 @@ class ApplicationController < ActionController::Base
   def recent_processes lim
     lim = 12 if lim.nil?
 
-    pipelines = PipelineInstance.limit(lim).order(["created_at desc"])
+    cols = %w(uuid owner_uuid created_at modified_at pipeline_template_uuid name state started_at finished_at)
+    pipelines = PipelineInstance.select(cols).limit(lim).order(["created_at desc"])
 
     crs = ContainerRequest.limit(lim).order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]])
     procs = {}
@@ -866,7 +868,7 @@ class ApplicationController < ActionController::Base
 
   helper_method :recent_collections
   def recent_collections lim
-    c = Collection.limit(lim).order(["modified_at desc"]).filter([["owner_uuid", "is_a", "arvados#group"]])
+    c = Collection.limit(lim).order(["modified_at desc"]).results
     own = {}
     Group.filter([["uuid", "in", c.map(&:owner_uuid)]]).each do |g|
       own[g[:uuid]] = g
@@ -1212,4 +1214,10 @@ class ApplicationController < ActionController::Base
   def wiselinks_layout
     'body'
   end
+
+  def set_current_request_id
+    # Request ID format: '<timestamp>-<9_digits_random_number>'
+    current_request_id = "#{Time.new.to_i}-#{sprintf('%09d', rand(0..10**9-1))}"
+    Thread.current[:current_request_id] = current_request_id
+  end
 end