Merge branch '19129-wb1-dashboard-speedup' refs #19129
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 20 May 2022 16:05:14 +0000 (12:05 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 20 May 2022 16:05:14 +0000 (12:05 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/views/projects/_show_dashboard.html.erb

index f8c8079a1edf4f5878c456d8f4ea0893e2574a32..7481575a6111c437761af84afa802018bfba9d63 100644 (file)
@@ -912,7 +912,8 @@ class ApplicationController < ActionController::Base
       pipelines.results.each { |pi| procs[pi] = pi.created_at }
     end
 
-    crs = ContainerRequest.limit(lim).with_count("none").order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]])
+    crs = ContainerRequest.limit(lim).with_count("none").order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]]).select(
+      ["uuid", "name", "container_uuid", "output_uuid", "state", "created_at", "modified_at"])
     crs.results.each { |c| procs[c] = c.created_at }
 
     Hash[procs.sort_by {|key, value| value}].keys.reverse.first(lim)
@@ -1244,7 +1245,7 @@ class ApplicationController < ActionController::Base
 
   # helper method to preload objects for given dataclass and uuids
   helper_method :preload_objects_for_dataclass
-  def preload_objects_for_dataclass dataclass, uuids, by_attr=nil
+  def preload_objects_for_dataclass dataclass, uuids, by_attr=nil, select_fields=nil
     @objects_for ||= {}
 
     raise ArgumentError, 'Argument is not a data class' unless dataclass.is_a? Class
@@ -1269,7 +1270,7 @@ class ApplicationController < ActionController::Base
       end
     else
       key_prefix = "request_#{Thread.current.object_id}_#{dataclass.to_s}_"
-      dataclass.where(uuid: uuids).each do |obj|
+      dataclass.where(uuid: uuids).select(select_fields).each do |obj|
         @objects_for[obj.uuid] = obj
         if dataclass == Collection
           # The collecions#index defaults to "all attributes except manifest_text"
index 6c58cd30fc723f7a662b2b6b6728cb719519136b..61ceaf9feca2e0eebac11b9f0a0f6fafa5165678 100644 (file)
@@ -8,7 +8,10 @@ SPDX-License-Identifier: AGPL-3.0 %>
   # preload container_uuids of any container requests
   recent_crs = recent_procs.map {|p| p if p.is_a?(ContainerRequest)}.compact.uniq
   recent_cr_containers = recent_crs.map {|cr| cr.container_uuid}.compact.uniq
-  preload_objects_for_dataclass(Container, recent_cr_containers) if recent_cr_containers.andand.any?
+  if recent_cr_containers.andand.any?
+    preload_objects_for_dataclass(Container, recent_cr_containers, nil,
+                               ["uuid", "started_at", "finished_at", "state", "runtime_status", "created_at", "modified_at", "exit_code"])
+  end
 
   wus = {}
   outputs = []