10078: preload collections and links during dashboard display
authorradhika <radhika@curoverse.com>
Sat, 1 Oct 2016 02:54:09 +0000 (22:54 -0400)
committerradhika <radhika@curoverse.com>
Fri, 7 Oct 2016 18:33:59 +0000 (14:33 -0400)
apps/workbench/app/views/projects/_show_dashboard.html.erb
apps/workbench/config/application.default.yml

index 806ed8a7735edb898725ea9744168176d1f02a7c..c1e3b6e0cb48761c09472d2d3a20d68460d7fb65 100644 (file)
@@ -1,3 +1,29 @@
+<%
+  recent_procs = recent_processes(10)
+
+  wus = {}
+  outputs = []
+  recent_procs.each do |p|
+    wu = p.work_unit
+    wus[p] = wu
+    outputs << wu.outputs
+  end
+  outputs = outputs.flatten.uniq
+
+  collection_pdhs = outputs.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
+  collection_uuids = outputs - collection_pdhs
+
+  if !Rails.configuration.suppress_collections_in_dashboard
+    recent_cs = recent_collections(8)
+    collection_uuids = collection_uuids + recent_cs[:collections].collect {|c| c.uuid}
+    collection_uuids.flatten.uniq
+  end
+
+  preload_collections_for_objects collection_uuids if collection_uuids.any?
+  preload_for_pdhs collection_pdhs if collection_pdhs.any?
+  preload_links_for_objects(collection_pdhs + collection_uuids)
+%>
+
   <div class="row">
     <div class="col-md-6">
       <div class="panel panel-default" style="min-height: 10.5em">
           <% end %>
         </div>
 
-        <% _recent_processes = recent_processes(12) %>
         <div class="panel-body recent-processes">
-          <% if _recent_processes.empty? %>
+          <% if recent_procs.empty? %>
             No recent pipelines or processes.
           <% else %>
-          <% _recent_processes.each do |p| %>
-            <% wu = p.work_unit %>
+          <% wus.each do |p, wu| %>
             <% if wu.is_finished? %>
             <div class="dashboard-panel-info-row row-<%=wu.uuid%>">
               <div class="row">
           </div>
         </div>
       </div>
+      <% if !Rails.configuration.suppress_collections_in_dashboard %>
       <div class="panel panel-default">
         <div class="panel-heading"><span class="panel-title">Recent collections</span>
           <span class="pull-right">
           </span>
         </div>
         <div class="panel-body">
-          <% r = recent_collections(8) %>
-          <% r[:collections].each do |p| %>
+          <% recent_cs[:collections].each do |p| %>
             <div class="dashboard-panel-info-row">
               <div>
-                <i class="fa fa-fw fa-folder-o"></i><%= link_to_if_arvados_object r[:owners][p[:owner_uuid]], friendly_name: true %>/
+                <i class="fa fa-fw fa-folder-o"></i><%= link_to_if_arvados_object recent_cs[:owners][p[:owner_uuid]], friendly_name: true %>/
                 <span class="pull-right"><%= render_localized_date(p[:modified_at], "noseconds") %></span>
               </div>
               <div class="text-overflow-ellipsis" style="margin-left: 1em; width: 100%"><%= link_to_if_arvados_object p, {friendly_name: true, no_tags: true} %>
           <% end %>
         </div>
       </div>
+      <% end %>
     </div>
   </div>
index 74d317bdf0ef3c537b0d10101568f377acc86395..5e5f4e9488ee145339f304d34f658dbf74187940 100644 (file)
@@ -280,3 +280,7 @@ common:
   # Maximum number of historic log records of a running job to fetch
   # and display in the Log tab, while subscribing to web sockets.
   running_job_log_records_to_fetch: 2000
+
+  # In systems with many shared projects, dashboard loading can be slow
+  # due to collections indexing; hide the recent collections panel
+  suppress_collections_in_dashboard: false