11580: preload container / container_request objects of the parent container / contai... 11580-cr-display-perf
authorradhika <radhika@curoverse.com>
Mon, 15 May 2017 23:50:44 +0000 (19:50 -0400)
committerradhika <radhika@curoverse.com>
Mon, 15 May 2017 23:50:44 +0000 (19:50 -0400)
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/models/container_work_unit.rb
apps/workbench/app/views/work_units/_show_status.html.erb

index a63fe6e21f1311a353392a2bc2f27f656147bee5..0a40f58f21512b479f130fa6de773eac9703700a 100644 (file)
@@ -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
index 84fc1f8f0978e16a86bd34fde8d07a6d2d9cd7c1..afdc91e4dd1fcb55d574b919da597e6cd93fa07b 100644 (file)
@@ -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
index f2052ef0edead69473db5cfeee18518898089eff..ea6920c1e2be5275bbc119dc3fbd89f875cad1c3 100644 (file)
@@ -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>