adds stats for direct messages and proposal notifications

This commit is contained in:
rgarcia
2016-06-16 17:42:16 +02:00
parent 31fc2ae927
commit 0abc9c8376
6 changed files with 95 additions and 1 deletions

View File

@@ -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_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 @user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals
@spending_proposals = SpendingProposal.count @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
end end

View File

@@ -0,0 +1,27 @@
<%= render 'shared/back_link' %>
<h2><%= t("admin.stats.direct_messages.title")%></h2>
<div class="stats row-full">
<div class="row">
<div class="small-12 column">
<div class="row stats-numbers">
<div class="small-12 medium-3 column">
<p class="featured">
<%= t("admin.stats.direct_messages.total") %><br>
<span class="number"><%= @direct_messages.count %></span>
</p>
</div>
<div class="small-12 medium-3 column">
<p class="featured">
<%= t("admin.stats.direct_messages.users_who_have_sent_message") %><br>
<span class="number"><%= @users_who_have_sent_message.count %></span>
</p>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,35 @@
<%= render 'shared/back_link' %>
<h2><%= t("admin.stats.proposal_notifications.title")%></h2>
<div class="stats row-full">
<div class="row">
<div class="small-12 column">
<div class="row stats-numbers">
<div class="small-12 medium-3 column">
<p class="featured">
<%= t("admin.stats.proposal_notifications.total") %><br>
<span class="number"><%= @proposal_notifications.count %></span>
</p>
</div>
<div class="small-12 medium-3 column">
<p class="featured">
<%= t("admin.stats.proposal_notifications.proposals_with_notifications") %><br>
<span class="number"><%= @proposals_with_notifications.count %></span>
</p>
</div>
</div>
</div>
</div>
</div>
<div id="proposal_notifications">
<% @proposal_notifications.each do |notification| %>
<p><%= link_to notification.proposal.title, proposal_path(notification.proposal) %></p>
<p><%= notification.title %></p>
<p><%= notification.body %></p>
<% end %>
</div>

View File

@@ -6,6 +6,17 @@
<div class="small-12 column"> <div class="small-12 column">
<h1><%= t "admin.stats.show.stats_title" %></h1> <h1><%= t "admin.stats.show.stats_title" %></h1>
<div class="row">
<div class="small-24 medium-6 column">
<%= link_to t("admin.stats.show.direct_messages"),
direct_messages_admin_stats_path %>
</div>
<div class="small-24 medium-6 column">
<%= link_to t("admin.stats.show.proposal_notifications"),
proposal_notifications_admin_stats_path %>
</div>
</div>
<div class="row stats-numbers"> <div class="row stats-numbers">
<div class="small-12 medium-3 column"> <div class="small-12 medium-3 column">
<p class="featured"> <p class="featured">

View File

@@ -286,6 +286,15 @@ es:
votes: Votos votes: Votos
spending_proposals_title: Propuestas de inversión spending_proposals_title: Propuestas de inversión
visits_title: Visitas 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: tags:
create: Crear Tema create: Crear Tema
destroy: Eliminar Tema destroy: Eliminar Tema

View File

@@ -182,7 +182,10 @@ Rails.application.routes.draw do
end end
resource :activity, controller: :activity, only: :show 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 namespace :api do
resource :stats, only: :show resource :stats, only: :show