Display the same results for stats and recounts
In the recounts we were incorrectly assuming the total amount included the blank and invalid ballots.
This commit is contained in:
@@ -2,14 +2,12 @@ class Admin::Poll::RecountsController < Admin::Poll::BaseController
|
||||
before_action :load_poll
|
||||
|
||||
def index
|
||||
@stats = Poll::Stats.new(@poll)
|
||||
|
||||
@booth_assignments = @poll.booth_assignments.
|
||||
includes(:booth, :recounts, :voters).
|
||||
order("poll_booths.name").
|
||||
page(params[:page]).per(50)
|
||||
@all_booths_counts = {
|
||||
final: ::Poll::Recount.select(:total_amount).where(booth_assignment_id: @poll.booth_assignment_ids).sum(:total_amount),
|
||||
system: ::Poll::Voter.where(booth_assignment_id: @poll.booth_assignment_ids).count
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -93,6 +93,10 @@ class Poll::Stats
|
||||
super + total_unregistered_booth
|
||||
end
|
||||
|
||||
def total_registered_booth
|
||||
voters.where(origin: "booth").count
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def participant_ids
|
||||
@@ -107,10 +111,6 @@ class Poll::Stats
|
||||
@recounts ||= poll.recounts
|
||||
end
|
||||
|
||||
def total_registered_booth
|
||||
voters.where(origin: "booth").count
|
||||
end
|
||||
|
||||
def total_unregistered_booth
|
||||
[total_participants_booth - total_registered_booth, 0].max
|
||||
end
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
<tr>
|
||||
<td><strong><%= t("admin.recounts.index.all_booths_total") %></strong></td>
|
||||
<% unless @poll.budget_poll? %>
|
||||
<td class="text-center" id="total_final"><%= @all_booths_counts[:final] %></td>
|
||||
<td class="text-center" id="total_final"><%= @stats.total_participants_booth %></td>
|
||||
<% end %>
|
||||
<td class="text-center" id="total_system"><%= @all_booths_counts[:system] %></td>
|
||||
<td class="text-center" id="total_system"><%= @stats.total_registered_booth %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -273,7 +273,7 @@ describe "Admin polls" do
|
||||
end
|
||||
|
||||
2.times do
|
||||
create(:poll_voter, poll: poll, booth_assignment: booth_assignment_final_recounted)
|
||||
create(:poll_voter, :from_booth, poll: poll, booth_assignment: booth_assignment_final_recounted)
|
||||
end
|
||||
|
||||
create(:poll_recount,
|
||||
|
||||
Reference in New Issue
Block a user