diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index abfecdd7f..8cc5d712c 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -21,6 +21,15 @@ class Admin::StatsController < Admin::BaseController @user_ids_who_voted_proposals = ActsAsVotable::Vote.where(votable_type: 'Proposal').distinct.count(:voter_id) @user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals @spending_proposals = SpendingProposal.count + end + def proposal_notifications + @proposal_notifications = ProposalNotification.all + @proposals_with_notifications = @proposal_notifications.pluck(:proposal_id).uniq + end + + def direct_messages + @direct_messages = DirectMessage.all + @users_who_have_sent_message = DirectMessage.pluck(:sender_id).uniq end end diff --git a/app/views/admin/stats/direct_messages.html.erb b/app/views/admin/stats/direct_messages.html.erb new file mode 100644 index 000000000..33c6ff517 --- /dev/null +++ b/app/views/admin/stats/direct_messages.html.erb @@ -0,0 +1,27 @@ +<%= render 'shared/back_link' %> + +
+ <%= t("admin.stats.direct_messages.total") %>
+ <%= @direct_messages.count %>
+
+ <%= t("admin.stats.direct_messages.users_who_have_sent_message") %>
+ <%= @users_who_have_sent_message.count %>
+
+ <%= t("admin.stats.proposal_notifications.total") %>
+ <%= @proposal_notifications.count %>
+
+ <%= t("admin.stats.proposal_notifications.proposals_with_notifications") %>
+ <%= @proposals_with_notifications.count %>
+
<%= link_to notification.proposal.title, proposal_path(notification.proposal) %>
+<%= notification.title %>
+<%= notification.body %>
+ <% end %> +diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index eef5ce10e..62778a194 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -286,6 +286,15 @@ es: votes: Votos spending_proposals_title: Propuestas de inversión visits_title: Visitas + direct_messages: Mensajes directos + proposal_notifications: Notificaciones de propuestas + direct_messages: + title: Mensajes directos + users_who_have_sent_message: Usuarios que han enviado un mensaje privado + proposal_notifications: + title: Mensajes directos + total: Total + proposals_with_notifications: Propuestas con notificaciones tags: create: Crear Tema destroy: Eliminar Tema diff --git a/config/routes.rb b/config/routes.rb index d805683d3..ed2ee34e4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -182,7 +182,10 @@ Rails.application.routes.draw do end resource :activity, controller: :activity, only: :show - resource :stats, only: :show + resource :stats, only: :show do + get :proposal_notifications, on: :collection + get :direct_messages, on: :collection + end namespace :api do resource :stats, only: :show