Remove geozone participation percentage
We currently don't store geozone population.
This commit is contained in:
@@ -75,11 +75,8 @@ module Statisticable
|
||||
[
|
||||
geozone.name,
|
||||
{
|
||||
total: {
|
||||
count: count,
|
||||
percentage: calculate_percentage(count, total_participants)
|
||||
},
|
||||
percentage: calculate_percentage(count, geozone.users.count)
|
||||
count: count,
|
||||
percentage: calculate_percentage(count, total_participants)
|
||||
}
|
||||
]
|
||||
end.to_h
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<tr>
|
||||
<th><%= t("stats.geozone") %></th>
|
||||
<th><%= t("stats.total") %></th>
|
||||
<th><%= t("stats.geozone_participation") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -14,8 +13,7 @@
|
||||
<% stats.participants_by_geozone.each do |geozone, participants| %>
|
||||
<tr>
|
||||
<td><%= geozone %></td>
|
||||
<td><%= "#{participants[:total][:count]} (#{number_to_stats_percentage(participants[:total][:percentage])})" %></td>
|
||||
<td><%= number_to_stats_percentage(participants[:percentage]) %></td>
|
||||
<td><%= "#{participants[:count]} (#{number_to_stats_percentage(participants[:percentage])})" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -13,7 +13,6 @@ en:
|
||||
age_range: "%{start} - %{finish} years old"
|
||||
total: "Total"
|
||||
geozone: "District"
|
||||
geozone_participation: "% District population participants"
|
||||
budgets:
|
||||
link: "Stats"
|
||||
page_title: "%{budget} - Participation stats"
|
||||
|
||||
@@ -13,7 +13,6 @@ es:
|
||||
age_range: "De %{start} a %{finish} años"
|
||||
total: "Total"
|
||||
geozone: "Distrito"
|
||||
geozone_participation: "% Participantes población del distrito"
|
||||
budgets:
|
||||
link: "Estadísticas"
|
||||
page_title: "%{budget} - Estadísticas de participación"
|
||||
|
||||
@@ -170,17 +170,10 @@ describe Poll::Stats do
|
||||
3.times { create :poll_voter, poll: poll, user: create(:user, :level_two, geozone: hobbiton) }
|
||||
2.times { create :poll_voter, poll: poll, user: create(:user, :level_two, geozone: rivendel) }
|
||||
|
||||
expect(stats.participants_by_geozone["Hobbiton"][:total]).to eq(count: 3, percentage: 60.0)
|
||||
expect(stats.participants_by_geozone["Rivendel"][:total]).to eq(count: 2, percentage: 40.0)
|
||||
end
|
||||
|
||||
it "calculates percentage relative to the geozone population" do
|
||||
midgar = create(:geozone, name: "Midgar")
|
||||
|
||||
create(:poll_voter, poll: poll, user: create(:user, :level_two, geozone: midgar))
|
||||
2.times { create :user, :level_two, geozone: midgar }
|
||||
|
||||
expect(stats.participants_by_geozone["Midgar"][:percentage]).to eq(33.333)
|
||||
expect(stats.participants_by_geozone["Hobbiton"][:count]).to eq 3
|
||||
expect(stats.participants_by_geozone["Hobbiton"][:percentage]).to eq 60.0
|
||||
expect(stats.participants_by_geozone["Rivendel"][:count]).to eq 2
|
||||
expect(stats.participants_by_geozone["Rivendel"][:percentage]).to eq 40.0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user