Skip to content

Commit

Permalink
chore: update Sample search to include project namespace and parent t…
Browse files Browse the repository at this point in the history
…o reduce extra queries
  • Loading branch information
ericenns committed Nov 27, 2024
1 parent 26b657a commit 31e55b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/components/samples/table_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<% end %>
<% if column == :puid || column == :name %>
<%= link_to(
project_sample_path(sample.project, sample),
namespace_project_sample_path(sample.project.namespace.parent, sample.project, sample),
data: { turbo: false },
class: "text-slate-700 dark:text-slate-300 font-semibold hover:underline"
) do %>
Expand All @@ -116,7 +116,7 @@
<% end %>
<% elsif column == :project_id %>
<%= link_to sample.project.puid,
project_samples_path(sample.project),
namespace_project_samples_path(sample.project.namespace.parent, sample.project),
data: {
turbo: false,
},
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/groups/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def index
end
)),
order: sort,
includes: [:project])
includes: [project: { namespace: [{ parent: :route }, :route] }])
@pagy, @samples = pagy_searchkick(collection, limit: params[:limit] || 20)
@has_samples = true
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/projects/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def index
end
)),
order: sort,
includes: [:project])
includes: [project: { namespace: [{ parent: :route }, :route] }])
@pagy, @samples = pagy_searchkick(collection, limit: params[:limit] || 20)
@has_samples = @project.samples.size.positive?
end
Expand Down

0 comments on commit 31e55b9

Please sign in to comment.