diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb new file mode 100644 index 000000000..4d7755994 --- /dev/null +++ b/app/controllers/stats_controller.rb @@ -0,0 +1,22 @@ +class StatsController < ApplicationController + include FeatureFlags + + feature_flag :public_stats + + skip_authorization_check + + def index + @visits = Visit.count + @debates = Debate.with_hidden.count + @proposals = Proposal.with_hidden.count + @comments = Comment.with_hidden.count + + @debate_votes = Vote.where(votable_type: 'Debate').count + @proposal_votes = Vote.where(votable_type: 'Proposal').count + @comment_votes = Vote.where(votable_type: 'Comment').count + @votes = Vote.count + + @verified_users = User.with_hidden.level_two_or_three_verified.count + @unverified_users = User.with_hidden.unverified.count + end +end diff --git a/app/views/stats/index.html.erb b/app/views/stats/index.html.erb new file mode 100644 index 000000000..4065c3c40 --- /dev/null +++ b/app/views/stats/index.html.erb @@ -0,0 +1,64 @@ +
+
+
+

<%= 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/config/locales/en.yml b/config/locales/en.yml index 699923c5a..7f6f30fe4 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -418,6 +418,18 @@ en: recommendation_two: Any proposal or comment suggesting illegal action will be deleted. recommendations_title: How to create a spending proposal start_new: Create spending proposal + 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 otes + 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/es.yml b/config/locales/es.yml index a69f3c364..68cd7f33c 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -419,6 +419,18 @@ es: recommendation_two: Cualquier propuesta o comentario que implique acciones ilegales será eliminada. recommendations_title: Cómo crear una propuesta de gasto start_new: Crear una propuesta de gasto + 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/routes.rb b/config/routes.rb index b48b4628f..749d3f5ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -67,6 +67,8 @@ Rails.application.routes.draw do resources :spending_proposals, only: [:index, :new, :create] + resources :stats, only: [:index] + resources :legislations, only: [:show] resources :annotations do