Add gender stats to polls
This commit is contained in:
@@ -2030,10 +2030,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.number {
|
|
||||||
font-size: rem-calc(60);
|
|
||||||
font-weight: bold;
|
|
||||||
line-height: rem-calc(60);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,58 @@
|
|||||||
border-bottom: 1px solid $border;
|
border-bottom: 1px solid $border;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section section {
|
||||||
|
clear: both;
|
||||||
|
margin-top: rem-calc(30);
|
||||||
|
margin-bottom: rem-calc(30);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
font-size: rem-calc(20);
|
font-size: rem-calc(20);
|
||||||
margin-bottom: 0;
|
margin-bottom: rem-calc(12);
|
||||||
margin-top: rem-calc(30);
|
}
|
||||||
|
|
||||||
|
.participants {
|
||||||
|
$background-width: 52px;
|
||||||
|
|
||||||
|
float: left;
|
||||||
|
margin-left: $background-width;
|
||||||
|
margin-right: rem-calc(22);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
// TODO: change image and move it to a non-custom folder
|
||||||
|
content: image-url("custom/polls/stats_man.png");
|
||||||
|
left: -$background-width;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number {
|
||||||
|
display: block;
|
||||||
|
font-size: rem-calc(60);
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: rem-calc(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
color: $dark-gray;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.gender {
|
||||||
|
|
||||||
|
&.male {
|
||||||
|
&::before {
|
||||||
|
content: image-url("custom/polls/stats_man.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.female {
|
||||||
|
&::before {
|
||||||
|
content: image-url("custom/polls/stats_woman.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,19 @@ class Poll::Stats
|
|||||||
alias_method :poll, :resource
|
alias_method :poll, :resource
|
||||||
|
|
||||||
def self.stats_methods
|
def self.stats_methods
|
||||||
%i[total_participants total_participants_web total_web_valid total_web_white total_web_null
|
super +
|
||||||
total_participants_booth total_booth_valid total_booth_white total_booth_null
|
%i[total_participants_web total_web_valid total_web_white total_web_null
|
||||||
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth
|
total_participants_booth total_booth_valid total_booth_white total_booth_null
|
||||||
total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage
|
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth
|
||||||
null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage
|
total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage
|
||||||
total_participants_booth_percentage]
|
null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage
|
||||||
|
total_participants_booth_percentage]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def participants
|
||||||
|
User.where(id: voters.pluck(:user_id))
|
||||||
|
end
|
||||||
|
|
||||||
def total_participants
|
def total_participants
|
||||||
total_participants_web + total_participants_booth
|
total_participants_web + total_participants_booth
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<%= link_to t("stats.total_participants"), "#total_participants" %>
|
<%= link_to t("stats.total_participants"), "#total_participants" %>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= link_to t("stats.by_gender"), "#participants_by_gender" %>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -26,9 +29,29 @@
|
|||||||
<section id="total_participants">
|
<section id="total_participants">
|
||||||
<h3><%= t("stats.total_participants") %></h3>
|
<h3><%= t("stats.total_participants") %></h3>
|
||||||
|
|
||||||
<p class="margin-top uppercase">
|
<p class="participants">
|
||||||
<%= t("polls.show.stats.total_votes") %><br>
|
|
||||||
<span class="number"><%= @stats[:total_participants] %></span>
|
<span class="number"><%= @stats[:total_participants] %></span>
|
||||||
|
<span class="info"><%= t("polls.show.stats.total_votes") %><br></span>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="participants_by_gender">
|
||||||
|
<h3><%= t("stats.by_gender") %></h3>
|
||||||
|
|
||||||
|
<p class="gender male participants">
|
||||||
|
<span class="number"><%= @stats[:total_male_participants] %></span>
|
||||||
|
<span class="info">
|
||||||
|
<%= I18n.t("stats.men_percentage",
|
||||||
|
percentage: number_to_stats_percentage(@stats[:male_percentage])) %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="gender female participants">
|
||||||
|
<span class="number"><%= @stats[:total_female_participants] %></span>
|
||||||
|
<span class="info">
|
||||||
|
<%= I18n.t("stats.women_percentage",
|
||||||
|
percentage: number_to_stats_percentage(@stats[:female_percentage])) %>
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ en:
|
|||||||
total_participants_booths: Vote phase booth participants
|
total_participants_booths: Vote phase booth participants
|
||||||
participants: Participants
|
participants: Participants
|
||||||
supports: Supports
|
supports: Supports
|
||||||
by_gender: "Participants by gender"
|
|
||||||
total_male_participants: Mens
|
total_male_participants: Mens
|
||||||
total_female_participants: Women
|
total_female_participants: Women
|
||||||
by_age: "Participants by age groups"
|
by_age: "Participants by age groups"
|
||||||
|
|||||||
@@ -2,3 +2,6 @@ en:
|
|||||||
stats:
|
stats:
|
||||||
title: "Participation data"
|
title: "Participation data"
|
||||||
total_participants: "Participants"
|
total_participants: "Participants"
|
||||||
|
by_gender: "Participants by gender"
|
||||||
|
men_percentage: "%{percentage} Men"
|
||||||
|
women_percentage: "%{percentage} Women"
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ es:
|
|||||||
participants: Participantes
|
participants: Participantes
|
||||||
supports: Apoyos
|
supports: Apoyos
|
||||||
total: Total
|
total: Total
|
||||||
by_gender: "Participación por género"
|
|
||||||
total_male_participants: Hombres
|
total_male_participants: Hombres
|
||||||
total_female_participants: Mujeres
|
total_female_participants: Mujeres
|
||||||
by_age: "Participación por grupos de edad"
|
by_age: "Participación por grupos de edad"
|
||||||
|
|||||||
@@ -2,3 +2,6 @@ es:
|
|||||||
stats:
|
stats:
|
||||||
title: "Estadísticas de participación"
|
title: "Estadísticas de participación"
|
||||||
total_participants: "Participantes"
|
total_participants: "Participantes"
|
||||||
|
by_gender: "Participación por género"
|
||||||
|
men_percentage: "%{percentage} Hombres"
|
||||||
|
women_percentage: "%{percentage} Mujeres"
|
||||||
|
|||||||
Reference in New Issue
Block a user