Remove public stats
This page isn't linked from anywhere and most Consul Democracy installations don't even know it exists, so it's useless for most people. If we ever bring it back, we should at least add a link pointing to this page.
This commit is contained in:
@@ -6,7 +6,6 @@ class Admin::Settings::FeaturesTabComponent < ApplicationComponent
|
||||
feature.google_login
|
||||
feature.twitter_login
|
||||
feature.wordpress_login
|
||||
feature.public_stats
|
||||
feature.signature_sheets
|
||||
feature.user.recommendations
|
||||
feature.user.recommendations_on_debates
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
class StatsController < ApplicationController
|
||||
include FeatureFlags
|
||||
|
||||
feature_flag :public_stats
|
||||
|
||||
skip_authorization_check
|
||||
|
||||
def index
|
||||
@visits = daily_cache("visits") { Visit.count }
|
||||
@debates = daily_cache("debates") { Debate.with_hidden.count }
|
||||
@proposals = daily_cache("proposals") { Proposal.with_hidden.count }
|
||||
@comments = daily_cache("comments") { Comment.not_valuations.with_hidden.count }
|
||||
|
||||
@debate_votes = daily_cache("debate_votes") { Vote.count_for("Debate") }
|
||||
@proposal_votes = daily_cache("proposal_votes") { Vote.count_for("Proposal") }
|
||||
@comment_votes = daily_cache("comment_votes") { Vote.count_for("Comment") }
|
||||
@investment_votes = daily_cache("budget_investment_votes") { Vote.count_for("Budget::Investment") }
|
||||
@votes = daily_cache("votes") { Vote.count }
|
||||
|
||||
@verified_users = daily_cache("verified_users") { User.with_hidden.level_two_or_three_verified.count }
|
||||
@unverified_users = daily_cache("unverified_users") { User.with_hidden.unverified.count }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def daily_cache(key, &)
|
||||
Rails.cache.fetch("public_stats/#{Time.current.strftime("%Y-%m-%d")}/#{key}", &)
|
||||
end
|
||||
end
|
||||
@@ -70,7 +70,6 @@ class Setting < ApplicationRecord
|
||||
"feature.google_login": true,
|
||||
"feature.twitter_login": true,
|
||||
"feature.wordpress_login": false,
|
||||
"feature.public_stats": true,
|
||||
"feature.signature_sheets": true,
|
||||
"feature.user.recommendations": true,
|
||||
"feature.user.recommendations_on_debates": true,
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<div class="stats row-full">
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<h1><%= t "admin.stats.show.stats_title" %></h1>
|
||||
|
||||
<div class="row stats-numbers">
|
||||
<div class="small-12 medium-4 column">
|
||||
<p class="featured">
|
||||
<%= t "stats.index.visits" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@visits) %></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= t "stats.index.debates" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@debates) %></span>
|
||||
</p>
|
||||
<p>
|
||||
<%= t "stats.index.proposals" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@proposals) %></span>
|
||||
</p>
|
||||
<p>
|
||||
<%= t "stats.index.comments" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@comments) %></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<p class="featured">
|
||||
<%= t "stats.index.proposal_votes" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@proposal_votes) %><br></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= t "stats.index.debate_votes" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@debate_votes) %></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= t "stats.index.comment_votes" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@comment_votes) %></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= t "stats.index.votes" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@votes) %></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<p class="featured">
|
||||
<%= t "stats.index.verified_users" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@verified_users) %></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= t "stats.index.unverified_users" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@unverified_users) %></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"<%= t("stats.index.visits") %>" : "<%= number_with_delimiter(@visits) %>",
|
||||
"<%= t("stats.index.debates") %>" : "<%= number_with_delimiter(@debates) %>",
|
||||
"<%= t("stats.index.proposals") %>" : "<%= number_with_delimiter(@proposals) %>",
|
||||
"<%= t("stats.index.comments") %>" : "<%= number_with_delimiter(@comments) %>",
|
||||
"<%= t("stats.index.proposal_votes") %>" : "<%= number_with_delimiter(@proposal_votes) %>",
|
||||
"<%= t("stats.index.debate_votes") %>" : "<%= number_with_delimiter(@debate_votes) %>",
|
||||
"<%= t("stats.index.comment_votes") %>" : "<%= number_with_delimiter(@comment_votes) %>",
|
||||
"<%= t("stats.index.votes") %>" : "<%= number_with_delimiter(@votes) %>",
|
||||
"<%= t("stats.index.verified_users") %>" : "<%= number_with_delimiter(@verified_users) %>",
|
||||
"<%= t("stats.index.unverified_users") %>" : "<%= number_with_delimiter(@unverified_users) %>"
|
||||
}
|
||||
@@ -761,18 +761,6 @@ en:
|
||||
youtube: "%{org} YouTube"
|
||||
telegram: "%{org} Telegram"
|
||||
instagram: "%{org} Instagram"
|
||||
stats:
|
||||
index:
|
||||
visits: Visits
|
||||
debates: Debates
|
||||
proposals: Proposals
|
||||
comments: Comments
|
||||
proposal_votes: Votes on proposals
|
||||
debate_votes: Votes on debates
|
||||
comment_votes: Votes on comments
|
||||
votes: Total votes
|
||||
verified_users: Verified users
|
||||
unverified_users: Unverified users
|
||||
unauthorized:
|
||||
default: You do not have permission to access this page.
|
||||
manage:
|
||||
|
||||
@@ -116,8 +116,6 @@ en:
|
||||
allow_attached_documents_description: "Allows users to upload documents when creating proposals and investment projects from Participatory Budgets"
|
||||
guides: "Guides to create proposals or investment projects"
|
||||
guides_description: "Displays a guide to differences between proposals and investment projects if there is an active participatory budget"
|
||||
public_stats: "Public stats"
|
||||
public_stats_description: "Display public stats in the Administration panel"
|
||||
help_page: "Help page"
|
||||
help_page_description: 'Displays a Help menu that contains a page with an info section about each enabled feature. Also custom pages and menus can be created in the "Custom pages" and "Custom content blocks" sections'
|
||||
remote_translations: "Remote translation"
|
||||
|
||||
@@ -761,18 +761,6 @@ es:
|
||||
youtube: "YouTube de %{org}"
|
||||
telegram: "Telegram de %{org}"
|
||||
instagram: "Instagram de %{org}"
|
||||
stats:
|
||||
index:
|
||||
visits: Visitas
|
||||
debates: Debates
|
||||
proposals: Propuestas ciudadanas
|
||||
comments: Comentarios
|
||||
proposal_votes: Votos en propuestas
|
||||
debate_votes: Votos en debates
|
||||
comment_votes: Votos en comentarios
|
||||
votes: Votos
|
||||
verified_users: Usuarios verificados
|
||||
unverified_users: Usuarios sin verificar
|
||||
unauthorized:
|
||||
default: No tienes permiso para acceder a esta página.
|
||||
manage:
|
||||
|
||||
@@ -116,8 +116,6 @@ es:
|
||||
allow_attached_documents_description: "Permite que los usuarios suban documentos al crear propuestas y proyectos de gasto de los Presupuestos participativos"
|
||||
guides: "Guías para crear propuestas o proyectos de inversión"
|
||||
guides_description: "Muestra una guía de diferencias entre las propuestas y los proyectos de gasto si hay un presupuesto participativo activo"
|
||||
public_stats: "Estadísticas públicas"
|
||||
public_stats_description: "Muestra las estadísticas públicas en el panel de Administración"
|
||||
help_page: "Página de ayuda"
|
||||
help_page_description: 'Muestra un menú Ayuda que contiene una página con una sección de información sobre cada funcionalidad habilitada. También se pueden crear páginas y menús personalizados en las secciones "Personalizar páginas" y "Personalizar bloques"'
|
||||
remote_translations: "Traducciones remotas"
|
||||
|
||||
@@ -32,7 +32,6 @@ Rails.application.routes.draw do
|
||||
get "/consul.json", to: "installation#details"
|
||||
get "robots.txt", to: "robots#index"
|
||||
|
||||
resources :stats, only: [:index]
|
||||
resources :images, only: [:destroy]
|
||||
resources :documents, only: [:destroy]
|
||||
resources :follows, only: [:create, :destroy]
|
||||
|
||||
@@ -164,14 +164,15 @@ describe "Notifications" do
|
||||
end
|
||||
|
||||
scenario "With internal link" do
|
||||
admin_notification.update!(link: "/stats")
|
||||
admin_notification.update!(link: "/debates")
|
||||
|
||||
visit notifications_path
|
||||
expect(page).to have_content("Notification title")
|
||||
expect(page).to have_content("Notification body")
|
||||
|
||||
first("#notification_#{notification.id} a").click
|
||||
expect(page).to have_current_path("/stats")
|
||||
|
||||
expect(page).to have_current_path "/debates"
|
||||
end
|
||||
|
||||
scenario "Without a link" do
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Stats" do
|
||||
context "Summary" do
|
||||
scenario "General" do
|
||||
create(:debate)
|
||||
2.times { create(:proposal) }
|
||||
3.times { create(:comment, commentable: Debate.first) }
|
||||
4.times { create(:visit) }
|
||||
|
||||
visit stats_path
|
||||
|
||||
expect(page).to have_content "DEBATES\n1"
|
||||
expect(page).to have_content "PROPOSALS\n2"
|
||||
expect(page).to have_content "COMMENTS\n3"
|
||||
expect(page).to have_content "VISITS\n4"
|
||||
end
|
||||
|
||||
scenario "Votes" do
|
||||
create(:debate, voters: Array.new(1) { create(:user) })
|
||||
create(:proposal, voters: Array.new(2) { create(:user) })
|
||||
create(:comment, voters: Array.new(3) { create(:user) })
|
||||
|
||||
visit stats_path
|
||||
|
||||
expect(page).to have_content "VOTES ON DEBATES\n1"
|
||||
expect(page).to have_content "VOTES ON PROPOSALS\n2"
|
||||
expect(page).to have_content "VOTES ON COMMENTS\n3"
|
||||
expect(page).to have_content "TOTAL VOTES\n6"
|
||||
end
|
||||
|
||||
scenario "Users" do
|
||||
1.times { create(:user, :level_three) }
|
||||
2.times { create(:user, :level_two) }
|
||||
2.times { create(:user) }
|
||||
|
||||
visit stats_path
|
||||
|
||||
expect(page).to have_content "VERIFIED USERS\n3"
|
||||
expect(page).to have_content "UNVERIFIED USERS\n2"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user