Skip to content

Commit

Permalink
Adding where clause to align counts on two pages
Browse files Browse the repository at this point in the history
On the "vitals" page, there is a count that we derive from
`number_of_works`.  When you click on the `link_to_field` that new page
also as a count based on the provided facets.  Prior to this commit, I
believe the underlying queries were not using the same logic.

With this change, I hope to bring this in alignment.

Please note, I don't have tests to confirm this, nor a data state that
would help confirm it.  So, I'm pushing up a change that I believe
should work.

My plan is to write some helper tests at a later date, but for now am
drawing to the end of my work day.

Related to #3478
  • Loading branch information
jeremyf committed Sep 15, 2020
1 parent 980dc92 commit 212cf16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/helpers/hyrax/hyrax_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ def search_action_for_dashboard
# rubocop:enable Metrics/MethodLength

# @param [ActionController::Parameters] params first argument for Blacklight::SearchState.new
# @param [Hash] facet
# @param [Hash] facet(s)
# @return [Hash]
#
# @note Assumes one facet is passed in. If a second facet is passed, then it must be the depositor
# facet used by the Profile page.
def search_state_with_facets(params, facet = {})
Expand Down
3 changes: 2 additions & 1 deletion app/views/hyrax/users/_vitals.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
</div>

<div class="list-group-item">
<span class="badge"><%= number_of_works(user) %></span>
<%# "Note the `{ generic_type_sim: "Work" }` for number_of_works aligns with the link_to_field's {generic_type: 'Work'} key/value pair." %>
<span class="badge"><%= number_of_works(user, where: { generic_type_sim: "Work" }) %></span>
<span class="glyphicon glyphicon-upload" aria-hidden="true"></span> <%= link_to_field('', '', t("hyrax.dashboard.stats.works"), {generic_type: "Work", depositor: user.to_s}) %>

<ul class="views-downloads-dashboard list-unstyled">
Expand Down

0 comments on commit 212cf16

Please sign in to comment.