[ARVADOS] created: 1d45ac3d39144c25180f10db5c55f78b12410efe

Git user git at public.curoverse.com
Mon May 15 19:51:48 EDT 2017


        at  1d45ac3d39144c25180f10db5c55f78b12410efe (commit)


commit 1d45ac3d39144c25180f10db5c55f78b12410efe
Author: radhika <radhika at curoverse.com>
Date:   Mon May 15 19:50:44 2017 -0400

    11580: preload container / container_request objects of the parent container / container_request.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index a63fe6e..0a40f58 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -1234,8 +1234,15 @@ class ApplicationController < ActionController::Base
         @objects_for[obj.name] = obj
       end
     else
+      key_prefix = "request_#{Thread.current.object_id}_#{dataclass.to_s}_"
       dataclass.where(uuid: uuids).each do |obj|
         @objects_for[obj.uuid] = obj
+        if dataclass == Collection
+          # The collecions#index defaults to "all attributes except manifest_text"
+          # Hence, this object is not suitable for preloading the find() cache.
+        else
+          Rails.cache.write(key_prefix + obj.uuid, obj.as_json)
+        end
       end
     end
     @objects_for
diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb
index 84fc1f8..afdc91e 100644
--- a/apps/workbench/app/models/container_work_unit.rb
+++ b/apps/workbench/app/models/container_work_unit.rb
@@ -6,7 +6,7 @@ class ContainerWorkUnit < ProxyWorkUnit
     if @proxied.is_a?(ContainerRequest)
       container_uuid = get(:container_uuid)
       if container_uuid
-        @container = Container.where(uuid: container_uuid).first
+        @container = Container.find(container_uuid)
       end
     end
   end
diff --git a/apps/workbench/app/views/work_units/_show_status.html.erb b/apps/workbench/app/views/work_units/_show_status.html.erb
index f2052ef..ea6920c 100644
--- a/apps/workbench/app/views/work_units/_show_status.html.erb
+++ b/apps/workbench/app/views/work_units/_show_status.html.erb
@@ -1,3 +1,16 @@
+<%
+    container_uuid = if @object.is_a?(Container) then @object.uuid else @object.container_uuid end
+    if container_uuid
+      reqs = ContainerRequest.where(requesting_container_uuid: container_uuid).results
+      child_crs = reqs.map(&:uuid).uniq
+      preload_objects_for_dataclass(ContainerRequest, child_crs)
+
+      child_cs = reqs.map(&:requesting_container_uuid).uniq
+      child_cs += reqs.map(&:container_uuid).uniq
+      preload_objects_for_dataclass(Container, child_cs)
+    end
+%>
+
 <div class="arv-log-refresh-control"
      data-load-throttle="86486400000" <%# 1001 nights %>
      ></div>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list