From 631b48f5866e80a81f2ef271c6bd786c6ff0004e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 26 Apr 2024 01:03:07 +0200 Subject: [PATCH] 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. --- .../admin/settings/features_tab_component.rb | 1 - app/controllers/stats_controller.rb | 29 --------- app/models/setting.rb | 1 - app/views/stats/index.html.erb | 63 ------------------- app/views/stats/index.json.erb | 12 ---- config/locales/en/general.yml | 12 ---- config/locales/en/settings.yml | 2 - config/locales/es/general.yml | 12 ---- config/locales/es/settings.yml | 2 - config/routes.rb | 1 - spec/system/notifications_spec.rb | 5 +- spec/system/stats_spec.rb | 43 ------------- 12 files changed, 3 insertions(+), 180 deletions(-) delete mode 100644 app/controllers/stats_controller.rb delete mode 100644 app/views/stats/index.html.erb delete mode 100644 app/views/stats/index.json.erb delete mode 100644 spec/system/stats_spec.rb diff --git a/app/components/admin/settings/features_tab_component.rb b/app/components/admin/settings/features_tab_component.rb index 64e0ffce2..2feae25cd 100644 --- a/app/components/admin/settings/features_tab_component.rb +++ b/app/components/admin/settings/features_tab_component.rb @@ -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 diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb deleted file mode 100644 index 15cfd7bb8..000000000 --- a/app/controllers/stats_controller.rb +++ /dev/null @@ -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 diff --git a/app/models/setting.rb b/app/models/setting.rb index 97fb97890..5427afccf 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -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, diff --git a/app/views/stats/index.html.erb b/app/views/stats/index.html.erb deleted file mode 100644 index e34341ba8..000000000 --- a/app/views/stats/index.html.erb +++ /dev/null @@ -1,63 +0,0 @@ -
-
-
-

<%= t "admin.stats.show.stats_title" %>

- -
-
- - -

- <%= 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.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.unverified_users" %>
- <%= number_with_delimiter(@unverified_users) %> -

-
- -
-
-
diff --git a/app/views/stats/index.json.erb b/app/views/stats/index.json.erb deleted file mode 100644 index c2c27702f..000000000 --- a/app/views/stats/index.json.erb +++ /dev/null @@ -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) %>" -} diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index f8c76bb55..755d67391 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -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: diff --git a/config/locales/en/settings.yml b/config/locales/en/settings.yml index de6059657..d1efc19a6 100644 --- a/config/locales/en/settings.yml +++ b/config/locales/en/settings.yml @@ -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" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 507ee7701..d8b03580f 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -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: diff --git a/config/locales/es/settings.yml b/config/locales/es/settings.yml index 08d0b3ae8..13261a050 100644 --- a/config/locales/es/settings.yml +++ b/config/locales/es/settings.yml @@ -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" diff --git a/config/routes.rb b/config/routes.rb index 29a4083c6..3d64fe247 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/spec/system/notifications_spec.rb b/spec/system/notifications_spec.rb index e0139659e..c79cf239e 100644 --- a/spec/system/notifications_spec.rb +++ b/spec/system/notifications_spec.rb @@ -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 diff --git a/spec/system/stats_spec.rb b/spec/system/stats_spec.rb deleted file mode 100644 index 595f737d2..000000000 --- a/spec/system/stats_spec.rb +++ /dev/null @@ -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