Skip to content

Commit

Permalink
Fix the count of records
Browse files Browse the repository at this point in the history
When counting the total number of searched records, we are incorrectly
using the paged values.

This change ensures we count the total records before applying
pagination.
  • Loading branch information
felixclack committed Sep 27, 2024
1 parent 48b7ae6 commit ea269ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/controllers/check_records/bulk_searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def show

data = @bulk_search_response.body
@total = @bulk_search_response.total
@total_not_found = data['not_found'].count
@total_results = data['results'].count
@results ||= data.fetch("results", []).map do |teacher|
QualificationsApi::Teacher.new(teacher['api_data'])
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/check_records/bulk_searches/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<% content_for :page_title, "Bulk Search Results" %>
<% content_for :breadcrumbs do %>
<%= govuk_breadcrumbs(breadcrumbs: { "Home" => check_records_search_path, "Find multiple records" => new_check_records_bulk_search_path, "Results" => nil }) %>
<%= render ActionAtComponent.new(action: "searched") %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<%= render ActionAtComponent.new(action: "searched") %>
<h1 class="govuk-heading-l"><%= pluralize(@total, 'teacher record') %> found</h1>
<p class="govuk-body govuk-!-margin-bottom-6">
We found <%= pluralize(@total, 'teacher record') %> out of the <%= pluralize(@results.count + @not_found.count, 'entry') %> you uploaded.
We found <%= pluralize(@total, 'teacher record') %> out of the <%= pluralize(@total_results + @total_not_found, 'entry') %> you uploaded.
</p>
<%= govuk_tabs do |tabs|
if @results.any?
Expand Down

0 comments on commit ea269ef

Please sign in to comment.