Skip to content

Commit

Permalink
Merge pull request #5928 from avalonmediasystem/search_but_not_found
Browse files Browse the repository at this point in the history
Don't show "Found in:" if no found in hits exist
  • Loading branch information
masaball authored Jul 12, 2024
2 parents 48bc3cf + 1906db6 commit 191a312
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def current_sort_field

def display_found_in(document)
metadata_count = document.to_h.sum {|k,v| k =~ /metadata_tf_/ ? v : 0 }
transcript_count = document["sections"]["docs"].sum { |d| d["transcripts"]["docs"].sum {|s| s.sum {|k,v| k =~ /transcript_tf_/ ? v : 0 }}}
transcript_count = document["sections"]["docs"].sum { |d| Array(d.dig("transcripts", "docs")).sum {|s| s.sum {|k,v| k =~ /transcript_tf_/ ? v : 0 }}}
section_count = document.to_h.sum {|k,v| k =~ /structure_tf_/ ? v : 0 }

metadata = "metadata (#{metadata_count})" if metadata_count > 0
Expand Down
4 changes: 2 additions & 2 deletions app/views/catalog/_index_media_object.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Unless required by applicable law or agreed to in writing, software distributed
<dd class="blacklight-<%= field_presenter.key %> col-sm-9"><%= field_presenter.values.join(', ') %></dd>
<% end %>
<% end %>
<% if params[:q].present? %>
<% if params[:q].present? && (found_in_hits = display_found_in(doc_presenter.document)).present? %>
<dt class="blacklight-found_in col-sm-3">Found in:</dt>
<dd class="blacklight-found_in col-sm-9"><%= display_found_in(doc_presenter.document) %></dd>
<dd class="blacklight-found_in col-sm-9"><%= found_in_hits %></dd>
<% end %>
</dl>

0 comments on commit 191a312

Please sign in to comment.