diff --git a/app/models/budget/stats.rb b/app/models/budget/stats.rb index d47139aae..c7e162c81 100644 --- a/app/models/budget/stats.rb +++ b/app/models/budget/stats.rb @@ -6,9 +6,11 @@ class Budget end def generate - stats = %w[total_participants total_participants_support_phase total_participants_vote_phase total_budget_investments total_votes - total_selected_investments total_unfeasible_investments total_male_participants total_female_participants total_supports - total_unknown_gender_or_age age_groups male_percentage female_percentage headings] + stats = %w[total_participants total_participants_support_phase total_participants_vote_phase + total_budget_investments total_votes total_selected_investments + 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 end @@ -22,6 +24,16 @@ class Budget stats_cache("total_participants_support_phase") { voters.uniq.count } 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 stats_cache("total_participants_vote_phase") { balloters.uniq.count } end @@ -96,7 +108,7 @@ class Budget def participants 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 diff --git a/app/views/budgets/stats/show.html.erb b/app/views/budgets/stats/show.html.erb index 0d41460ac..4c976343a 100644 --- a/app/views/budgets/stats/show.html.erb +++ b/app/views/budgets/stats/show.html.erb @@ -76,11 +76,18 @@ <%= @stats[:total_supports] %> <%= t("budgets.stats.supports") %>
-   - <%= t("budgets.stats.total_participants_vote_phase") %>: - - <%= @stats[:total_participants_vote_phase] %> <%= t("budgets.stats.participants") %>, - <%= @stats[:total_votes] %> <%= t("budgets.stats.votes") %>
+
+ +   + <%= t("budgets.stats.total_participants_web") %>: + + <%= @stats[:total_participants_web] %>
+
+ +   + <%= t("budgets.stats.total_participants_booths") %>: + + <%= @stats[:total_participants_booths] %>

diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml index b40bd8145..29a1ee813 100644 --- a/config/locales/en/budgets.yml +++ b/config/locales/en/budgets.yml @@ -200,6 +200,8 @@ en: total_selected_investments: Proposals on final phase total_unfeasible_investments: Unfeasible proposals total_participants_support_phase: Support phase + total_participants_web: Vote phase web participants + total_participants_booths: Vote phase booth participants participants: Participants supports: Supports votes: Votes diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml index 5f14ad8bd..226c560cb 100644 --- a/config/locales/es/budgets.yml +++ b/config/locales/es/budgets.yml @@ -200,6 +200,8 @@ es: total_selected_investments: Propuestas en la fase final total_unfeasible_investments: Propuestas inviables 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 supports: Apoyos votes: Votos diff --git a/spec/models/budget/stats_spec.rb b/spec/models/budget/stats_spec.rb index 78aea057c..7beafb4e0 100644 --- a/spec/models/budget/stats_spec.rb +++ b/spec/models/budget/stats_spec.rb @@ -68,6 +68,22 @@ describe Budget::Stats do 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 it "returns the number of total budget investments" do