gwu-libraries / scholarspace-hyrax

Hyrax-based repository for GW ETDs and other original content
https://scholarspace.library.gwu.edu/
MIT License
9 stars 4 forks source link

Sort-by not functioning on collections pages #414

Open kilahimm opened 10 months ago

kilahimm commented 10 months ago

On a collections page "Sort by" options do not result in any changes to the results.

dolsysmith commented 10 months ago

One place to look might be app/views/catalog/_index_list_default.html.erb, which we're overriding and which seems to have changed since Hyrax 2.96. Current Hyrax code is below:

<div class="col-md-6">
  <div class="metadata">
    <dl class="dl-horizontal">
    <% doc_presenter = index_presenter(document) %>
    <% index_fields(document).each do |field_name, field| -%>
      <% if should_render_index_field? document, field %>
          <dt data-solr-field-name="<%= field_name %>"><%= render_index_field_label document, field: field_name %></dt>
          <dd><%= doc_presenter.field_value field %></dd>
      <% end %>
    <% end %>
    </dl>
  </div>
</div>
<% if document.collection? %>
<% collection_presenter = Hyrax::CollectionPresenter.new(document, current_ability) %>
<div class="col-md-4">
  <div class="collection-counts-wrapper">
    <div class="collection-counts-item">
      <span><%= collection_presenter.total_viewable_collections %></span>Collections
    </div>
    <div class="collection-counts-item">
      <span><%= collection_presenter.total_viewable_works %></span>Works
    </div>
  </div>
</div>
<% end %>
maxturer commented 10 months ago

So it looks like _index_list_default.html.erb generates search results, but not the list of items on a collection page. I think I found the right template, app/views/hyrax/collections/_sort_and_per_page.html.erb... I will double check to see if we have any other old templates that might be conflicting with any new variables from the new version.

dolsysmith commented 10 months ago

Might be a good idea to update _index_list_default anyway, since the changes seem related to Blacklight deprecations: https://github.com/samvera/hyrax/commit/4a476aabf967e634ba54269794afb62982a129c0

dolsysmith commented 9 months ago

Another interesting clue from the logs:

On the Dashboard > Collection page, when selecting a type of sort from the dropdown, the correct parameters are added to the app URL:

http://ec2-18-222-180-6.us-east-2.compute.amazonaws.com/dashboard/collections/gh93gz487?utf8=%E2%9C%93&sort=system_create_dtsi+desc&per_page=10&locale=en

But the Solr query does not match the provided sort parameter:

2023-10-31 13:04:52.317 INFO  (qtp401424608-21) [   x:solr-core-dev] o.a.s.c.S.Request [solr-core-dev]  webapp=/solr path=/select params={facet.field=visibility_ssi&facet.field=suppressed_bsi&facet.field=resource_type_sim&facet.field=has_model_ssim&qt=search&facet.pivot=has_model_ssim,collection_type_gid_ssim&fq=&fq={!terms+f%3Dhas_model_ssim}Collection&fq=-suppressed_bsi:true&fq=-{!terms+f%3Did}gh93gz487&fq=_query_:"{!field+f%3Dcollection_type_gid_ssim}gid://scholarspace/Hyrax::CollectionType/2"&fq=-_query_:"{!lucene+q.op%3DOR+df%3Dnesting_collection__pathnames_ssim}gh93gz487"&fq=-_query_:"{!field+f%3Dnesting_collection__parent_ids_ssim}gh93gz487"&f.resource_type_sim.facet.limit=6&sort=title_si+asc&rows=1000&f.collection_type_gid_ssim.facet.limit=6&f.has_model_ssim.facet.limit=6&f.visibility_ssi.facet.limit=6&qf=title_tesim+description_tesim+creator_tesim+keyword_tesim&wt=json&facet=true} hits=0 status=0 QTime=0

So I'm thinking that some logic must be awry between the route and the controller, rather than the problem being in the view itself, which presumably works with the results as provided by Solr. In this case, Solr seems to be getting the wrong query. @alepbloyd Does that analysis sound right to you?

dolsysmith commented 9 months ago

This has been fixed by applying the patches suggested by the Samvera community members: https://github.com/gwu-libraries/scholarspace-hyrax/pull/437/commits/a715a4b8957db15a4d3f7af605c201f4f432a860

But the divergence from Hyrax 3 in _index_list_default.html.erb might still be worth attending to?