From 5b7762f1e6931c3e4e6ccd36d2a75ce53e38e36c Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 21 Aug 2014 14:44:30 -0400 Subject: [PATCH] 3036: Use preload_objects to fetch owner_uuids in the controller instead of in the view. --- apps/workbench/app/controllers/collections_controller.rb | 8 ++++++++ apps/workbench/app/views/collections/show.html.erb | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index a4925bdeb3..1cc4966ac8 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -170,6 +170,14 @@ class CollectionsController < ApplicationController .where(head_uuid: @object.uuid, link_class: 'name').results project_hash = Group.where(uuid: @project_links.map(&:tail_uuid)).to_hash @projects = project_hash.values + + if @object.uuid.match /[0-9a-f]{32}/ + @same_pdh = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]]) + owners = @same_pdh.map {|s| s.owner_uuid}.to_a + preload_objects_for_dataclass Group, owners + preload_objects_for_dataclass User, owners + end + @permissions = Link.limit(RELATION_LIMIT).order("modified_at DESC") .where(head_uuid: @object.uuid, link_class: 'permission', name: 'can_read').results diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb index cc19000725..7d8ac4dacb 100644 --- a/apps/workbench/app/views/collections/show.html.erb +++ b/apps/workbench/app/views/collections/show.html.erb @@ -35,11 +35,11 @@
- <% if @object.uuid.match /[0-9a-f]{32}/ %> + <% if defined? @same_pdh %>

Found in collections:

- <% cols = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]]).each do |c| %> - <%= link_to_if_arvados_object c.owner_uuid, {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %>
+ <% @same_pdh.each do |c| %> + <%= link_to_if_arvados_object get_object(c.owner_uuid), {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %>
<% end %>

<% else %> -- 2.30.2