From d58c2423e8e038e4c47c2329299059978abc7fbf Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 16 May 2022 16:22:30 -0400 Subject: [PATCH] 19129: Select specific fields to speed up dashboard loading Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- apps/workbench/app/controllers/application_controller.rb | 7 ++++--- apps/workbench/app/views/projects/_show_dashboard.html.erb | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index f8c8079a1e..7481575a61 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -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" diff --git a/apps/workbench/app/views/projects/_show_dashboard.html.erb b/apps/workbench/app/views/projects/_show_dashboard.html.erb index 6c58cd30fc..f26d89780b 100644 --- a/apps/workbench/app/views/projects/_show_dashboard.html.erb +++ b/apps/workbench/app/views/projects/_show_dashboard.html.erb @@ -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"]) + end wus = {} outputs = [] -- 2.30.2