From 220186e4b88838797b0686a2e82d2f47001e7532 Mon Sep 17 00:00:00 2001 From: j-corry Date: Mon, 11 Nov 2024 10:39:57 +0000 Subject: [PATCH 1/2] - Don't show session facets with 0 associated results --- .../results/facets/_session_facet.html.erb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/views/search/results/facets/_session_facet.html.erb b/app/views/search/results/facets/_session_facet.html.erb index b426e26..f5f59ca 100644 --- a/app/views/search/results/facets/_session_facet.html.erb +++ b/app/views/search/results/facets/_session_facet.html.erb @@ -5,18 +5,22 @@
<% SolrSearch.sessions[0..4].each do |session| %> -
- <%= link_to_unless(request.params.dig(:filter, "session")&.include?(session), "#{session} (#{number_to_delimited(facet_data.dig("session_#{session}", "count"), separator: ",")})", url_for(apply_filter_url(request.params, "session", session)), class: "menu-link modifiable-link") %> -
+ <% unless facet_data.dig("session_#{session}", "count") == 0 %> +
+ <%= link_to_unless(request.params.dig(:filter, "session")&.include?(session), "#{session} (#{number_to_delimited(facet_data.dig("session_#{session}", "count"), separator: ",")})", url_for(apply_filter_url(request.params, "session", session)), class: "menu-link modifiable-link") %> +
+ <% end %> <% end %> <% unless SolrSearch.sessions[5..].blank? %>
More <% SolrSearch.sessions[5..].each do |session| %> -
- <%= link_to_unless(request.params.dig(:filter, "session")&.include?(session), "#{session} (#{number_to_delimited(facet_data.dig("session_#{session}", "count"), separator: ",")})", url_for(apply_filter_url(request.params, "session", session)), class: "menu-link modifiable-link") %> -
+ <% unless facet_data.dig("session_#{session}", "count") == 0 %> +
+ <%= link_to_unless(request.params.dig(:filter, "session")&.include?(session), "#{session} (#{number_to_delimited(facet_data.dig("session_#{session}", "count"), separator: ",")})", url_for(apply_filter_url(request.params, "session", session)), class: "menu-link modifiable-link") %> +
+ <% end %> <% end %>
<% end %> From 274aada64b1547905d85b9938ac223fbcf2ee4eb Mon Sep 17 00:00:00 2001 From: j-corry Date: Mon, 11 Nov 2024 11:50:57 +0000 Subject: [PATCH 2/2] - Don't show type facet entries where there are no matching records --- app/views/search/_hierarchy_layer.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/search/_hierarchy_layer.html.erb b/app/views/search/_hierarchy_layer.html.erb index ae200f4..bcc0885 100644 --- a/app/views/search/_hierarchy_layer.html.erb +++ b/app/views/search/_hierarchy_layer.html.erb @@ -1,4 +1,4 @@ -<% if id %> +<% if id && @type_facets[id] %>
<% if @hierarchy_data.dig(id, :children).any? %>