Create SDG stats page

This commit is contained in:
Senén Rodero Rodríguez
2021-01-21 14:56:30 +01:00
parent 4c2d918bb5
commit 9b2d349e21
9 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
<%= back_link_to %>
<%= header %>
<%= render Admin::Stats::SDG::GoalComponent.with_collection(goals) %>

View File

@@ -0,0 +1,15 @@
class Admin::Stats::SDGComponent < ApplicationComponent
include Header
attr_reader :goals
def initialize(goals)
@goals = goals
end
private
def title
t("admin.stats.sdg.title")
end
end

View File

@@ -90,6 +90,10 @@ class Admin::StatsController < Admin::BaseController
@participants = ::Poll::Voter.where(poll: @polls) @participants = ::Poll::Voter.where(poll: @polls)
end end
def sdg
@goals = SDG::Goal.order(:code)
end
private private
def voters_in_heading(heading) def voters_in_heading(heading)

View File

@@ -0,0 +1 @@
<%= render Admin::Stats::SDGComponent.new(@goals) %>

View File

@@ -14,6 +14,8 @@
proposal_notifications_admin_stats_path, class: "button hollow" %> proposal_notifications_admin_stats_path, class: "button hollow" %>
<%= link_to t("admin.stats.show.incomplete_verifications"), <%= link_to t("admin.stats.show.incomplete_verifications"),
admin_verifications_path, class: "button hollow" %> admin_verifications_path, class: "button hollow" %>
<%= link_to t("admin.stats.show.sdg"),
sdg_admin_stats_path, class: "button hollow" if feature?(:sdg) %>
</div> </div>
<div class="clear"></div> <div class="clear"></div>

View File

@@ -1373,6 +1373,7 @@ en:
proposal_notifications: Proposal notifications proposal_notifications: Proposal notifications
incomplete_verifications: Incomplete verifications incomplete_verifications: Incomplete verifications
polls: Polls polls: Polls
sdg: SDG
graph: graph:
debate_created: Debates debate_created: Debates
visit: Visits visit: Visits
@@ -1423,6 +1424,7 @@ en:
debates: "Debates" debates: "Debates"
polls: "Polls" polls: "Polls"
proposals: "Proposals" proposals: "Proposals"
title: "Sustainable Development Goals - Stats"
tags: tags:
create: Create topic create: Create topic
destroy: Delete topic destroy: Delete topic

View File

@@ -1372,6 +1372,7 @@ es:
proposal_notifications: Notificaciones de propuestas proposal_notifications: Notificaciones de propuestas
incomplete_verifications: Verificaciones incompletas incomplete_verifications: Verificaciones incompletas
polls: Votaciones polls: Votaciones
sdg: ODS
graph: graph:
debate_created: Debates debate_created: Debates
visit: Visitas visit: Visitas
@@ -1422,6 +1423,7 @@ es:
debates: "Debates" debates: "Debates"
polls: "Votaciones" polls: "Votaciones"
proposals: "Propuestas" proposals: "Propuestas"
title: "Objetivos de Desarrollo Sostenible - Estadísticas"
tags: tags:
create: Crear tema create: Crear tema
destroy: Eliminar tema destroy: Eliminar tema

View File

@@ -204,6 +204,7 @@ namespace :admin do
get :proposal_notifications, on: :collection get :proposal_notifications, on: :collection
get :direct_messages, on: :collection get :direct_messages, on: :collection
get :polls, on: :collection get :polls, on: :collection
get :sdg, on: :collection
end end
namespace :legislation do namespace :legislation do

View File

@@ -395,4 +395,29 @@ describe "Stats", :admin do
end end
end end
end end
context "SDG", :js do
scenario "Shows SDG stats link when SDG feature is enabled" do
Setting["feature.sdg"] = true
visit admin_stats_path
expect(page).to have_link "SDG", href: sdg_admin_stats_path
end
scenario "Does not show SDG stats link when SDG feature is disbled" do
Setting["feature.sdg"] = false
visit admin_stats_path
expect(page).not_to have_link "SDG"
end
scenario "Renders all goals stats" do
visit sdg_admin_stats_path
expect(page).to have_css "h3", count: SDG::Goal.count
expect(page).to have_css ".sdg-goal-stats", count: SDG::Goal.count
end
end
end end