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;
|
||||
}
|
||||
|
||||
section section {
|
||||
clear: both;
|
||||
margin-top: rem-calc(30);
|
||||
margin-bottom: rem-calc(30);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: rem-calc(20);
|
||||
margin-bottom: 0;
|
||||
margin-top: rem-calc(30);
|
||||
margin-bottom: rem-calc(12);
|
||||
}
|
||||
|
||||
.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,7 +3,8 @@ class Poll::Stats
|
||||
alias_method :poll, :resource
|
||||
|
||||
def self.stats_methods
|
||||
%i[total_participants total_participants_web total_web_valid total_web_white total_web_null
|
||||
super +
|
||||
%i[total_participants_web total_web_valid total_web_white total_web_null
|
||||
total_participants_booth total_booth_valid total_booth_white total_booth_null
|
||||
total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth
|
||||
total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage
|
||||
@@ -12,6 +13,9 @@ class Poll::Stats
|
||||
end
|
||||
|
||||
private
|
||||
def participants
|
||||
User.where(id: voters.pluck(:user_id))
|
||||
end
|
||||
|
||||
def total_participants
|
||||
total_participants_web + total_participants_booth
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<li>
|
||||
<%= link_to t("stats.total_participants"), "#total_participants" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t("stats.by_gender"), "#participants_by_gender" %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -26,9 +29,29 @@
|
||||
<section id="total_participants">
|
||||
<h3><%= t("stats.total_participants") %></h3>
|
||||
|
||||
<p class="margin-top uppercase">
|
||||
<%= t("polls.show.stats.total_votes") %><br>
|
||||
<p class="participants">
|
||||
<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>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -202,7 +202,6 @@ en:
|
||||
total_participants_booths: Vote phase booth participants
|
||||
participants: Participants
|
||||
supports: Supports
|
||||
by_gender: "Participants by gender"
|
||||
total_male_participants: Mens
|
||||
total_female_participants: Women
|
||||
by_age: "Participants by age groups"
|
||||
|
||||
@@ -2,3 +2,6 @@ en:
|
||||
stats:
|
||||
title: "Participation data"
|
||||
total_participants: "Participants"
|
||||
by_gender: "Participants by gender"
|
||||
men_percentage: "%{percentage} Men"
|
||||
women_percentage: "%{percentage} Women"
|
||||
|
||||
@@ -203,7 +203,6 @@ es:
|
||||
participants: Participantes
|
||||
supports: Apoyos
|
||||
total: Total
|
||||
by_gender: "Participación por género"
|
||||
total_male_participants: Hombres
|
||||
total_female_participants: Mujeres
|
||||
by_age: "Participación por grupos de edad"
|
||||
|
||||
@@ -2,3 +2,6 @@ es:
|
||||
stats:
|
||||
title: "Estadísticas de participación"
|
||||
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