mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
optimization
This commit is contained in:
parent
6763d8e7a1
commit
740392c687
3 changed files with 13 additions and 21 deletions
|
@ -6,12 +6,4 @@ module SearchHelper
|
|||
end
|
||||
experiments.uniq
|
||||
end
|
||||
|
||||
def sub_results(el)
|
||||
elements = []
|
||||
el.each do |m|
|
||||
elements << m
|
||||
end
|
||||
elements.uniq
|
||||
end
|
||||
end
|
||||
|
|
|
@ -150,12 +150,12 @@ class Protocol < ActiveRecord::Base
|
|||
MyModule.joins(:protocols).where('protocols.parent_id = ?', id)
|
||||
end
|
||||
|
||||
def linked_experiments
|
||||
Experiment.where('id IN (?)', linked_modules.pluck(:experiment_id).uniq)
|
||||
def linked_experiments(linked_mod)
|
||||
Experiment.where('id IN (?)', linked_mod.pluck(:experiment_id).uniq)
|
||||
end
|
||||
|
||||
def linked_projects
|
||||
Project.where('id IN (?)', linked_experiments.pluck(:project_id).uniq)
|
||||
def linked_projects(linked_exp)
|
||||
Project.where('id IN (?)', linked_exp.pluck(:project_id).uniq)
|
||||
end
|
||||
|
||||
def self.new_blank_for_module(my_module)
|
||||
|
|
|
@ -50,12 +50,12 @@
|
|||
<br>
|
||||
<% if protocol.nr_of_linked_children > 0 %>
|
||||
<span>
|
||||
<% if protocol.linked_modules %>
|
||||
<% if protocol_linked_modules = protocol.linked_modules %>
|
||||
<%=t "search.index.modules" %>
|
||||
<% protocol.linked_modules.each_with_index do |mod, i| %>
|
||||
<% protocol_linked_modules.each_with_index do |mod, i| %>
|
||||
<%= render partial: "search/results/partials/my_module_text.html.erb",
|
||||
locals: { my_module: mod } %>
|
||||
<% if i != (sub_results(protocol.linked_modules).count - 1) %>
|
||||
<% if i != (protocol_linked_modules.count - 1) %>
|
||||
,
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -63,12 +63,12 @@
|
|||
</span>
|
||||
<br>
|
||||
<span>
|
||||
<% if protocol.linked_experiments %>
|
||||
<% if protocol_linked_experiments = protocol.linked_experiments(protocol_linked_modules) %>
|
||||
<%=t "search.index.experiment" %>
|
||||
<% protocol.linked_experiments.each_with_index do |exp, i| %>
|
||||
<% protocol_linked_experiments.each_with_index do |exp, i| %>
|
||||
<%= render partial: "search/results/partials/experiment_text.html.erb",
|
||||
locals: { experiment: exp } %>
|
||||
<% if i != (sub_results(protocol.linked_experiments).count - 1) %>
|
||||
<% if i != (protocol_linked_experiments.count - 1) %>
|
||||
,
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -76,12 +76,12 @@
|
|||
</span>
|
||||
<br>
|
||||
<span>
|
||||
<% if protocol.linked_projects %>
|
||||
<% if protocol_linked_projects = protocol.linked_projects(protocol_linked_experiments) %>
|
||||
<%=t "search.index.project" %>
|
||||
<% protocol.linked_projects.each_with_index do |pro, i| %>
|
||||
<% protocol_linked_projects.each_with_index do |pro, i| %>
|
||||
<%= render partial: "search/results/partials/project_text.html.erb",
|
||||
locals: { project: pro } %>
|
||||
<% if i != (sub_results(protocol.linked_projects).count - 1) %>
|
||||
<% if i != (protocol_linked_projects.count - 1) %>
|
||||
,
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue