adds stats for direct messages and proposal notifications
This commit is contained in:
@@ -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
|
||||
|
||||
27
app/views/admin/stats/direct_messages.html.erb
Normal file
27
app/views/admin/stats/direct_messages.html.erb
Normal 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>
|
||||
35
app/views/admin/stats/proposal_notifications.html.erb
Normal file
35
app/views/admin/stats/proposal_notifications.html.erb
Normal 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>
|
||||
@@ -6,6 +6,17 @@
|
||||
<div class="small-12 column">
|
||||
<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="small-12 medium-3 column">
|
||||
<p class="featured">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user