Make Stats a public page
This commit is contained in:
parent
9c59d634b0
commit
f84cd7f11b
6 changed files with 23 additions and 29 deletions
|
@ -1,24 +0,0 @@
|
||||||
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
|
|
21
app/controllers/stats_controller.rb
Normal file
21
app/controllers/stats_controller.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
class StatsController < ApplicationController
|
||||||
|
|
||||||
|
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
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
= f.submit 'Créer un administrateur', class: 'btn btn-success', id: 'submit_new_administrateur'
|
= f.submit 'Créer un administrateur', class: 'btn btn-success', id: 'submit_new_administrateur'
|
||||||
|
|
||||||
.text-center
|
|
||||||
= link_to 'Stats', administrations_stats_path, style: 'margin-bottom: 50px; display: block;', 'data-no-turbolink': true
|
|
||||||
|
|
||||||
= smart_listing_render :admins
|
= smart_listing_render :admins
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
|
|
@ -45,14 +45,14 @@ Rails.application.routes.draw do
|
||||||
authenticate :administration do
|
authenticate :administration do
|
||||||
resources :administrations, only: [:index, :create]
|
resources :administrations, only: [:index, :create]
|
||||||
namespace :administrations do
|
namespace :administrations do
|
||||||
resources :stats, only: [:index]
|
|
||||||
|
|
||||||
require 'sidekiq/web'
|
require 'sidekiq/web'
|
||||||
require 'sidekiq/cron/web'
|
require 'sidekiq/cron/web'
|
||||||
mount Sidekiq::Web => '/sidekiq'
|
mount Sidekiq::Web => '/sidekiq'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :stats, only: [:index]
|
||||||
|
|
||||||
namespace :france_connect do
|
namespace :france_connect do
|
||||||
get 'particulier' => 'particulier#login'
|
get 'particulier' => 'particulier#login'
|
||||||
get 'particulier/callback' => 'particulier#callback'
|
get 'particulier/callback' => 'particulier#callback'
|
||||||
|
|
Loading…
Add table
Reference in a new issue