Stats: add adminitrations stats view
This commit is contained in:
parent
2e19dd26b7
commit
6cb88a995f
5 changed files with 51 additions and 1 deletions
10
app/assets/stylesheets/administrations/stats.scss
Normal file
10
app/assets/stylesheets/administrations/stats.scss
Normal file
|
@ -0,0 +1,10 @@
|
|||
.stats {
|
||||
padding: 15px;
|
||||
|
||||
.stat-card {
|
||||
background-color: white;
|
||||
margin: 15px auto;
|
||||
max-width: 1200px;
|
||||
padding: 15px;
|
||||
}
|
||||
}
|
24
app/controllers/administrations/stats_controller.rb
Normal file
24
app/controllers/administrations/stats_controller.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Administrations
|
||||
class StatsController < ApplicationController
|
||||
before_action :authenticate_administration!
|
||||
|
||||
def index
|
||||
procedures = Procedure.where(created_at: Time.current.all_quarter).group("date_trunc('day', created_at)").count
|
||||
dossiers = Dossier.where(created_at: Time.current.all_quarter).group("date_trunc('day', created_at)").count
|
||||
@procedures = clean_hash(procedures)
|
||||
@dossiers = clean_hash(dossiers)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clean_hash h
|
||||
h.keys.each{ |key| h[key.to_date] = h[key]; h.delete(key) }
|
||||
min_date = h.keys.min
|
||||
max_date = h.keys.max
|
||||
(min_date..max_date).each do |date|
|
||||
h[date] = 0 if h[date].nil?
|
||||
end
|
||||
h
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
%br
|
||||
|
||||
.center
|
||||
=link_to 'Stats', administrations_stats_path, style: 'margin-bottom: 50px; display: block', 'data-no-turbolink': true
|
||||
|
||||
= smart_listing_render :admins
|
||||
|
||||
%br
|
||||
|
|
10
app/views/administrations/stats/index.html.haml
Normal file
10
app/views/administrations/stats/index.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
|||
= javascript_include_tag 'https://code.highcharts.com/highcharts.js', 'chartkick'
|
||||
|
||||
.stats
|
||||
.stat-card
|
||||
%h1 Procédures crées
|
||||
= line_chart @procedures
|
||||
|
||||
.stat-card
|
||||
%h1 Dossiers créés
|
||||
= line_chart @dossiers
|
|
@ -42,7 +42,10 @@ Rails.application.routes.draw do
|
|||
get 'admin' => 'admin#index'
|
||||
get 'backoffice' => 'backoffice#index'
|
||||
|
||||
resources :administrations
|
||||
resources :administrations, only: [:index, :create]
|
||||
namespace :administrations do
|
||||
resources :stats, only: [:index]
|
||||
end
|
||||
|
||||
namespace :france_connect do
|
||||
get 'particulier' => 'particulier#login'
|
||||
|
|
Loading…
Reference in a new issue