Merge pull request #4204 from betagouv/3945-procedure-stats
First attempt at procedure stats
This commit is contained in:
commit
b74b72d1c8
8 changed files with 83 additions and 7 deletions
|
@ -2,6 +2,13 @@
|
|||
@import "common";
|
||||
@import "constants";
|
||||
|
||||
.procedure-header {
|
||||
a.header-link {
|
||||
display: inline-block;
|
||||
margin-bottom: 1 * $default-padding;
|
||||
}
|
||||
}
|
||||
|
||||
#procedure-show {
|
||||
h1 {
|
||||
color: $black;
|
||||
|
@ -9,11 +16,6 @@
|
|||
margin-bottom: 1 * $default-padding;
|
||||
}
|
||||
|
||||
a.notifications {
|
||||
display: inline-block;
|
||||
margin-bottom: 1 * $default-padding;
|
||||
}
|
||||
|
||||
.dossiers-table {
|
||||
margin-top: $default-spacer;
|
||||
margin-bottom: 3 * $default-spacer;
|
||||
|
|
|
@ -53,7 +53,7 @@ $stat-card-half-horizontal-spacing: 4 * $default-space;
|
|||
|
||||
.stat-card-half {
|
||||
width: calc((100% - #{$stat-card-half-horizontal-spacing}) / 2);
|
||||
margin-right: 3 * $default-space;
|
||||
margin-right: $stat-card-half-horizontal-spacing;
|
||||
}
|
||||
|
||||
.stat-card-title {
|
||||
|
|
|
@ -205,6 +205,13 @@ module Instructeurs
|
|||
redirect_to instructeur_procedure_path(procedure)
|
||||
end
|
||||
|
||||
def stats
|
||||
@procedure = procedure
|
||||
@usual_traitement_time = @procedure.stats_usual_traitement_time
|
||||
@dossiers_funnel = @procedure.stats_dossiers_funnel
|
||||
@termines_states = @procedure.stats_termines_states
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_field(table, column)
|
||||
|
|
30
app/models/concerns/procedure_stats_concern.rb
Normal file
30
app/models/concerns/procedure_stats_concern.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module ProcedureStatsConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def stats_usual_traitement_time
|
||||
Rails.cache.fetch("#{cache_key_with_version}/stats_usual_traitement_time", expires_in: 12.hours) do
|
||||
usual_traitement_time
|
||||
end
|
||||
end
|
||||
|
||||
def stats_dossiers_funnel
|
||||
Rails.cache.fetch("#{cache_key_with_version}/stats_dossiers_funnel", expires_in: 12.hours) do
|
||||
[
|
||||
['Démarrés', dossiers.count],
|
||||
['Déposés', dossiers.state_not_brouillon.count],
|
||||
['Instruction débutée', dossiers.state_instruction_commencee.count],
|
||||
['Traités', dossiers.state_termine.count]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
def stats_termines_states
|
||||
Rails.cache.fetch("#{cache_key_with_version}/stats_termines_states", expires_in: 12.hours) do
|
||||
[
|
||||
['Acceptés', dossiers.where(state: :accepte).count],
|
||||
['Refusés', dossiers.where(state: :refuse).count],
|
||||
['Classés sans suite', dossiers.where(state: :sans_suite).count]
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,8 @@ require Rails.root.join('lib', 'percentile')
|
|||
class Procedure < ApplicationRecord
|
||||
self.ignored_columns = ['logo', 'logo_secure_token']
|
||||
|
||||
include ProcedureStatsConcern
|
||||
|
||||
MAX_DUREE_CONSERVATION = 36
|
||||
|
||||
has_many :types_de_champ, -> { root.public_only.ordered }, inverse_of: :procedure, dependent: :destroy
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
.procedure-header
|
||||
%h1= procedure_libelle @procedure
|
||||
= link_to 'configurez vos notifications', email_notifications_instructeur_procedure_path(@procedure), class: 'notifications'
|
||||
= link_to 'gestion des notifications', email_notifications_instructeur_procedure_path(@procedure), class: 'header-link'
|
||||
|
|
||||
= link_to 'statistiques', stats_instructeur_procedure_path(@procedure), class: 'header-link'
|
||||
|
||||
|
||||
%ul.tabs
|
||||
|
|
32
app/views/instructeurs/procedures/stats.html.haml
Normal file
32
app/views/instructeurs/procedures/stats.html.haml
Normal file
|
@ -0,0 +1,32 @@
|
|||
- title = "Statistiques · #{@procedure.libelle}"
|
||||
- content_for(:title, title)
|
||||
|
||||
= render partial: 'new_administrateur/breadcrumbs',
|
||||
locals: { steps: [link_to(@procedure.libelle, procedure_path(@procedure)),
|
||||
'Statistiques'] }
|
||||
|
||||
.statistiques
|
||||
%h1.new-h1= title
|
||||
.stat-cards
|
||||
- if @usual_traitement_time.present?
|
||||
.stat-card.big-number-card
|
||||
%span.big-number-card-title TEMPS DE TRAITEMENT USUEL
|
||||
%span.big-number-card-number
|
||||
= distance_of_time_in_words(@usual_traitement_time)
|
||||
%span.big-number-card-detail
|
||||
90% des demandes du mois dernier ont été traitées en moins de #{distance_of_time_in_words(@usual_traitement_time)}.
|
||||
|
||||
.stat-cards
|
||||
.stat-card.stat-card-half.pull-left
|
||||
%span.stat-card-title AVANCÉE DES DOSSIERS
|
||||
.chart-container
|
||||
.chart
|
||||
= area_chart @dossiers_funnel
|
||||
|
||||
.stat-card.stat-card-half.pull-left
|
||||
%span.stat-card-title TAUX D’ACCEPTATION
|
||||
.chart-container
|
||||
.chart
|
||||
- colors = %w(#C3D9FF #0069CC #1C7EC9) # from _colors.scss
|
||||
= pie_chart @termines_states, colors: colors
|
||||
|
|
@ -285,6 +285,7 @@ Rails.application.routes.draw do
|
|||
post 'add_filter'
|
||||
get 'remove_filter' => 'procedures#remove_filter', as: 'remove_filter'
|
||||
get 'download_dossiers'
|
||||
get 'stats'
|
||||
get 'email_notifications'
|
||||
patch 'update_email_notifications'
|
||||
|
||||
|
|
Loading…
Reference in a new issue