Simplify budget stats in voting phase

So we only show the total number of participants, and not divided by web
participants and booth participants.
This commit is contained in:
Javi Martín
2019-03-15 07:59:18 +01:00
parent d42454a1a8
commit dc077bb03c
5 changed files with 4 additions and 55 deletions

View File

@@ -6,8 +6,7 @@ class Budget::Stats
super + super +
%i[total_participants_support_phase total_participants_vote_phase %i[total_participants_support_phase total_participants_vote_phase
total_budget_investments total_votes total_selected_investments total_budget_investments total_votes total_selected_investments
total_unfeasible_investments total_supports headings total_unfeasible_investments headings]
total_participants_web total_participants_booths]
end end
def participants def participants
@@ -24,14 +23,6 @@ class Budget::Stats
voters.uniq.count voters.uniq.count
end end
def total_participants_web
(balloters - poll_ballot_voters).uniq.compact.count
end
def total_participants_booths
poll_ballot_voters.uniq.count
end
def total_participants_vote_phase def total_participants_vote_phase
(balloters + poll_ballot_voters).uniq.count (balloters + poll_ballot_voters).uniq.count
end end
@@ -52,10 +43,6 @@ class Budget::Stats
budget.investments.unfeasible.count budget.investments.unfeasible.count
end end
def total_supports
supports(budget).count
end
def authors def authors
budget.investments.pluck(:author_id) budget.investments.pluck(:author_id)
end end

View File

@@ -82,13 +82,9 @@
<h4><%= t("stats.budgets.by_phase") %></h4> <h4><%= t("stats.budgets.by_phase") %></h4>
<%= number_with_info_tags(@stats[:total_participants_support_phase], <%= number_with_info_tags(@stats[:total_participants_support_phase],
t("stats.budgets.participants")) %> t("stats.budgets.participants_support_phase")) %>
<%= number_with_info_tags(@stats[:total_participants_vote_phase],
<%= number_with_info_tags(@stats[:total_supports], t("stats.budgets.supports")) %> t("stats.budgets.participants_voting_phase")) %>
<%= number_with_info_tags(@stats[:total_participants_web],
t("stats.budgets.total_participants_web")) %>
<%= number_with_info_tags(@stats[:total_participants_booths],
t("stats.budgets.total_participants_booths")) %>
</div> </div>

View File

@@ -23,10 +23,6 @@ en:
total_selected_investments: "Projects in final voting phase" total_selected_investments: "Projects in final voting phase"
total_unfeasible_investments: "Unfeasible projects" total_unfeasible_investments: "Unfeasible projects"
by_phase: "Participants by phase" by_phase: "Participants by phase"
total_participants_web: "Vote phase web participants"
total_participants_booths: "Vote phase booth participants"
participants: "Participants"
supports: "Supports"
by_heading: "Participants by phase and heading" by_heading: "Participants by phase and heading"
total: "Total" total: "Total"
heading: "Heading" heading: "Heading"

View File

@@ -23,10 +23,6 @@ es:
total_selected_investments: "Proyectos en la fase final" total_selected_investments: "Proyectos en la fase final"
total_unfeasible_investments: "Proyectos inviables" total_unfeasible_investments: "Proyectos inviables"
by_phase: "Participación por fases" by_phase: "Participación por fases"
total_participants_web: "Participantes web en votación final"
total_participants_booths: "Participantes en urnas votación final"
participants: "Participantes"
supports: "Apoyos"
by_heading: "Participación por distritos y fase" by_heading: "Participación por distritos y fase"
total: "Total" total: "Total"
heading: "Distrito" heading: "Distrito"

View File

@@ -94,24 +94,6 @@ describe Budget::Stats do
end end
end end
describe "#total_participants_web" do
it "returns the number of total participants in the votes phase via web" do
2.times { create(:budget_ballot_line, investment: investment) }
create(:poll_voter, :from_booth, budget: budget)
expect(stats.generate[:total_participants_web]).to be 2
end
end
describe "#total_participants_booths" do
it "returns the number of total participants in the votes phase in booths" do
2.times { create(:poll_voter, :from_booth, budget: budget) }
create(:budget_ballot_line, investment: investment)
expect(stats.generate[:total_participants_booths]).to be 2
end
end
describe "#total_budget_investments" do describe "#total_budget_investments" do
it "returns the number of total budget investments" do it "returns the number of total budget investments" do
2.times { create(:budget_investment, budget: budget) } 2.times { create(:budget_investment, budget: budget) }
@@ -150,14 +132,6 @@ describe Budget::Stats do
end end
end end
describe "#total_supports" do
it "returns the number of total supports" do
2.times { create(:vote, votable: investment) }
expect(stats.generate[:total_supports]).to be 2
end
end
describe "Participants by gender" do describe "Participants by gender" do
before do before do
3.times { create(:user, gender: "male") } 3.times { create(:user, gender: "male") }