Add web and booth participants in budget stats
This commit is contained in:
@@ -6,9 +6,11 @@ class Budget
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generate
|
def generate
|
||||||
stats = %w[total_participants total_participants_support_phase total_participants_vote_phase total_budget_investments total_votes
|
stats = %w[total_participants total_participants_support_phase total_participants_vote_phase
|
||||||
total_selected_investments total_unfeasible_investments total_male_participants total_female_participants total_supports
|
total_budget_investments total_votes total_selected_investments
|
||||||
total_unknown_gender_or_age age_groups male_percentage female_percentage headings]
|
total_unfeasible_investments total_male_participants total_female_participants
|
||||||
|
total_supports total_unknown_gender_or_age age_groups male_percentage
|
||||||
|
female_percentage headings total_participants_web total_participants_booths]
|
||||||
stats.map { |stat_name| [stat_name.to_sym, send(stat_name)] }.to_h
|
stats.map { |stat_name| [stat_name.to_sym, send(stat_name)] }.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,6 +24,16 @@ class Budget
|
|||||||
stats_cache("total_participants_support_phase") { voters.uniq.count }
|
stats_cache("total_participants_support_phase") { voters.uniq.count }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def total_participants_web
|
||||||
|
stats_cache("total_participants_web") do
|
||||||
|
(balloters - poll_ballot_voters).uniq.compact.count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def total_participants_booths
|
||||||
|
stats_cache("total_participants_booths") { poll_ballot_voters.uniq.count }
|
||||||
|
end
|
||||||
|
|
||||||
def total_participants_vote_phase
|
def total_participants_vote_phase
|
||||||
stats_cache("total_participants_vote_phase") { balloters.uniq.count }
|
stats_cache("total_participants_vote_phase") { balloters.uniq.count }
|
||||||
end
|
end
|
||||||
@@ -96,7 +108,7 @@ class Budget
|
|||||||
|
|
||||||
def participants
|
def participants
|
||||||
stats_cache("participants") do
|
stats_cache("participants") do
|
||||||
User.where(id: (authors + voters + balloters + poll_ballot_voters).uniq)
|
User.where(id: (authors + voters + balloters + poll_ballot_voters).uniq.compact)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -76,11 +76,18 @@
|
|||||||
<%= @stats[:total_supports] %> <em><%= t("budgets.stats.supports") %></em><br>
|
<%= @stats[:total_supports] %> <em><%= t("budgets.stats.supports") %></em><br>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="label balloting"></span>
|
<br>
|
||||||
<span class="uppercase"><strong><%= t("budgets.stats.total_participants_vote_phase") %></strong></span>:
|
|
||||||
<span id="total_participants_vote_phase">
|
<span class="label"></span>
|
||||||
<%= @stats[:total_participants_vote_phase] %> <em><%= t("budgets.stats.participants") %></em>,
|
<span class="uppercase"><strong><%= t("budgets.stats.total_participants_web") %></strong></span>:
|
||||||
<%= @stats[:total_votes] %> <em><%= t("budgets.stats.votes") %></em><br>
|
<span id="total_participants_web">
|
||||||
|
<%= @stats[:total_participants_web] %><br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="label"></span>
|
||||||
|
<span class="uppercase"><strong><%= t("budgets.stats.total_participants_booths") %></strong></span>:
|
||||||
|
<span id="total_participants_booths">
|
||||||
|
<%= @stats[:total_participants_booths] %><br>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ en:
|
|||||||
total_selected_investments: Proposals on final phase
|
total_selected_investments: Proposals on final phase
|
||||||
total_unfeasible_investments: Unfeasible proposals
|
total_unfeasible_investments: Unfeasible proposals
|
||||||
total_participants_support_phase: Support phase
|
total_participants_support_phase: Support phase
|
||||||
|
total_participants_web: Vote phase web participants
|
||||||
|
total_participants_booths: Vote phase booth participants
|
||||||
participants: Participants
|
participants: Participants
|
||||||
supports: Supports
|
supports: Supports
|
||||||
votes: Votes
|
votes: Votes
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ es:
|
|||||||
total_selected_investments: Propuestas en la fase final
|
total_selected_investments: Propuestas en la fase final
|
||||||
total_unfeasible_investments: Propuestas inviables
|
total_unfeasible_investments: Propuestas inviables
|
||||||
total_participants_support_phase: Fase de apoyos
|
total_participants_support_phase: Fase de apoyos
|
||||||
|
total_participants_web: Participantes web en votación final
|
||||||
|
total_participants_booths: Participantes en urnas votación final
|
||||||
participants: Participantes
|
participants: Participantes
|
||||||
supports: Apoyos
|
supports: Apoyos
|
||||||
votes: Votos
|
votes: Votos
|
||||||
|
|||||||
@@ -68,6 +68,22 @@ describe Budget::Stats do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "#total_participants_web" do
|
||||||
|
|
||||||
|
it "returns the number of total participants in the votes phase via web" do
|
||||||
|
expect(@stats[:total_participants_web]).to be 3
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "#total_participants_booths" do
|
||||||
|
|
||||||
|
it "returns the number of total participants in the votes phase in booths" do
|
||||||
|
expect(@stats[:total_participants_booths]).to be 1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context "#total_budget_investments" do
|
context "#total_budget_investments" do
|
||||||
|
|
||||||
it "returns the number of total budget investments" do
|
it "returns the number of total budget investments" do
|
||||||
|
|||||||
Reference in New Issue
Block a user