Include no geozone in no demographic data
This commit is contained in:
@@ -41,8 +41,8 @@ module Statisticable
|
|||||||
participants.female.count
|
participants.female.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_unknown_gender_or_age
|
def total_no_demographic_data
|
||||||
participants.where("gender IS NULL OR date_of_birth is NULL").uniq.count
|
participants.where("gender IS NULL OR date_of_birth IS NULL OR geozone_id IS NULL").count
|
||||||
end
|
end
|
||||||
|
|
||||||
def male_percentage
|
def male_percentage
|
||||||
@@ -153,8 +153,7 @@ module Statisticable
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gender_methods
|
def gender_methods
|
||||||
%i[total_male_participants total_female_participants total_unknown_gender_or_age
|
%i[total_male_participants total_female_participants male_percentage female_percentage]
|
||||||
male_percentage female_percentage]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def age_methods
|
def age_methods
|
||||||
@@ -162,7 +161,7 @@ module Statisticable
|
|||||||
end
|
end
|
||||||
|
|
||||||
def geozone_methods
|
def geozone_methods
|
||||||
[:participants_by_geozone]
|
%i[participants_by_geozone total_no_demographic_data]
|
||||||
end
|
end
|
||||||
|
|
||||||
def stats_cache(*method_names)
|
def stats_cache(*method_names)
|
||||||
|
|||||||
@@ -145,9 +145,9 @@
|
|||||||
|
|
||||||
<div class="row margin">
|
<div class="row margin">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<div id="total_unknown_gender_or_age">
|
<div id="total_no_demographic_data">
|
||||||
<p class="help-text">
|
<p class="help-text">
|
||||||
<%= t("stats.budgets.no_demographic_data", total: @stats.total_unknown_gender_or_age) %>
|
<%= t("stats.no_demographic_data", total: @stats.total_no_demographic_data) %>
|
||||||
</p>
|
</p>
|
||||||
<p class="help-text">
|
<p class="help-text">
|
||||||
<%= t("stats.budgets.participatory_disclaimer") %>
|
<%= t("stats.budgets.participatory_disclaimer") %>
|
||||||
|
|||||||
@@ -114,6 +114,12 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="total_no_demographic_data">
|
||||||
|
<p class="help-text">
|
||||||
|
<%= t("stats.no_demographic_data", total: @stats.total_no_demographic_data) %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ en:
|
|||||||
age_range: "%{start} - %{finish} years old"
|
age_range: "%{start} - %{finish} years old"
|
||||||
total: "Total"
|
total: "Total"
|
||||||
geozone: "District"
|
geozone: "District"
|
||||||
|
no_demographic_data: "* There is no demographic data for %{total} participants."
|
||||||
budgets:
|
budgets:
|
||||||
link: "Stats"
|
link: "Stats"
|
||||||
page_title: "%{budget} - Participation stats"
|
page_title: "%{budget} - Participation stats"
|
||||||
@@ -29,7 +30,6 @@ en:
|
|||||||
participants_total: "Total Participants"
|
participants_total: "Total Participants"
|
||||||
percent_total_participants_html: "% <br>Total<br>Participants"
|
percent_total_participants_html: "% <br>Total<br>Participants"
|
||||||
percent_heading_census_html: "% <br>Heading<br>Census"
|
percent_heading_census_html: "% <br>Heading<br>Census"
|
||||||
no_demographic_data: "* There is no demographic data for %{total} participants."
|
|
||||||
participatory_disclaimer: "** The numbers of total participants refer to persons that created, supported or voted investment proposals."
|
participatory_disclaimer: "** The numbers of total participants refer to persons that created, supported or voted investment proposals."
|
||||||
heading_disclaimer: "*** Data about headings refer to the heading where each user voted, not necessarily the one that person is registered on."
|
heading_disclaimer: "*** Data about headings refer to the heading where each user voted, not necessarily the one that person is registered on."
|
||||||
polls:
|
polls:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ es:
|
|||||||
age_range: "De %{start} a %{finish} años"
|
age_range: "De %{start} a %{finish} años"
|
||||||
total: "Total"
|
total: "Total"
|
||||||
geozone: "Distrito"
|
geozone: "Distrito"
|
||||||
|
no_demographic_data: "* No se dispone de los datos demográficos de %{total} participantes."
|
||||||
budgets:
|
budgets:
|
||||||
link: "Estadísticas"
|
link: "Estadísticas"
|
||||||
page_title: "%{budget} - Estadísticas de participación"
|
page_title: "%{budget} - Estadísticas de participación"
|
||||||
@@ -29,7 +30,6 @@ es:
|
|||||||
participants_total: Total de participantes
|
participants_total: Total de participantes
|
||||||
percent_total_participants_html: "% <br>Total<br>Participantes"
|
percent_total_participants_html: "% <br>Total<br>Participantes"
|
||||||
percent_heading_census_html: "% <br>Censo<br>Distrito"
|
percent_heading_census_html: "% <br>Censo<br>Distrito"
|
||||||
no_demographic_data: "* No se dispone de los datos demográficos de %{total} participantes."
|
|
||||||
participatory_disclaimer: "** Las cifras de total de participantes se refieren a personas que han creado, apoyado o votado propuestas."
|
participatory_disclaimer: "** Las cifras de total de participantes se refieren a personas que han creado, apoyado o votado propuestas."
|
||||||
heading_disclaimer: "*** Los datos de distrito se refieren al distrito en el que el usuario ha votado, no necesariamente en el que está empadronado."
|
heading_disclaimer: "*** Los datos de distrito se refieren al distrito en el que el usuario ha votado, no necesariamente en el que está empadronado."
|
||||||
polls:
|
polls:
|
||||||
|
|||||||
@@ -153,12 +153,6 @@ describe Budget::Stats do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#total_unknown_gender_or_age" do
|
|
||||||
it "returns the number of total unknown participants' gender or age" do
|
|
||||||
expect(stats.total_unknown_gender_or_age).to be 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#male_percentage" do
|
describe "#male_percentage" do
|
||||||
it "returns the percentage of male participants" do
|
it "returns the percentage of male participants" do
|
||||||
expect(stats.male_percentage).to be 60.0
|
expect(stats.male_percentage).to be 60.0
|
||||||
|
|||||||
@@ -102,6 +102,38 @@ describe Statisticable do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#total_no_demographic_data" do
|
||||||
|
it "returns users with no defined gender" do
|
||||||
|
create(:user, gender: nil)
|
||||||
|
|
||||||
|
expect(stats.total_no_demographic_data).to be 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns users with no defined age" do
|
||||||
|
create(:user, gender: "female", date_of_birth: nil)
|
||||||
|
|
||||||
|
expect(stats.total_no_demographic_data).to be 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns users with no defined geozone" do
|
||||||
|
create(:user, gender: "female", geozone: nil)
|
||||||
|
|
||||||
|
expect(stats.total_no_demographic_data).to be 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns users with no defined gender, age nor geozone" do
|
||||||
|
create(:user, gender: nil, date_of_birth: nil, geozone: nil)
|
||||||
|
|
||||||
|
expect(stats.total_no_demographic_data).to be 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't return users with defined gender, age and geozone" do
|
||||||
|
create(:user, gender: "male", date_of_birth: 20.years.ago, geozone: create(:geozone))
|
||||||
|
|
||||||
|
expect(stats.total_no_demographic_data).to be 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#stats_methods" do
|
describe "#stats_methods" do
|
||||||
it "includes total participants" do
|
it "includes total participants" do
|
||||||
expect(stats.stats_methods).to include(:total_participants)
|
expect(stats.stats_methods).to include(:total_participants)
|
||||||
|
|||||||
Reference in New Issue
Block a user