First attempt at procedure stats

fixes #3945, #3946, #3948
This commit is contained in:
Nicolas Bouilleaud 2019-07-30 14:37:00 +02:00
parent 394a2773db
commit 3e2985b305
6 changed files with 62 additions and 7 deletions

View file

@ -2,6 +2,13 @@
@import "common"; @import "common";
@import "constants"; @import "constants";
.procedure-header {
a.header-link {
display: inline-block;
margin-bottom: 1 * $default-padding;
}
}
#procedure-show { #procedure-show {
h1 { h1 {
color: $black; color: $black;
@ -9,11 +16,6 @@
margin-bottom: 1 * $default-padding; margin-bottom: 1 * $default-padding;
} }
a.notifications {
display: inline-block;
margin-bottom: 1 * $default-padding;
}
.dossiers-table { .dossiers-table {
margin-top: $default-spacer; margin-top: $default-spacer;
margin-bottom: 3 * $default-spacer; margin-bottom: 3 * $default-spacer;

View file

@ -53,7 +53,7 @@ $stat-card-half-horizontal-spacing: 4 * $default-space;
.stat-card-half { .stat-card-half {
width: calc((100% - #{$stat-card-half-horizontal-spacing}) / 2); width: calc((100% - #{$stat-card-half-horizontal-spacing}) / 2);
margin-right: 3 * $default-space; margin-right: $stat-card-half-horizontal-spacing;
} }
.stat-card-title { .stat-card-title {

View file

@ -205,6 +205,24 @@ module Instructeurs
redirect_to instructeur_procedure_path(procedure) redirect_to instructeur_procedure_path(procedure)
end end
def stats
@procedure = procedure
@usual_traitement_time = procedure.usual_traitement_time
@dossiers_funnel = [
['Démarrés', procedure.dossiers.count],
['Déposés', procedure.dossiers.state_not_brouillon.count],
['Instruction débutée', procedure.dossiers.state_instruction_commencee.count],
['Traités', procedure.dossiers.state_termine.count]
]
@termines_states = [
['Acceptés', procedure.dossiers.where(state: :accepte).count],
['Refusés', procedure.dossiers.where(state: :refuse).count],
['Classés sans suite', procedure.dossiers.where(state: :sans_suite).count]
]
end
private private
def find_field(table, column) def find_field(table, column)

View file

@ -9,7 +9,9 @@
.procedure-header .procedure-header
%h1= procedure_libelle @procedure %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 %ul.tabs

View 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 DACCEPTATION
.chart-container
.chart
- colors = %w(#C3D9FF #0069CC #1C7EC9) # from _colors.scss
= pie_chart @termines_states, colors: colors

View file

@ -285,6 +285,7 @@ Rails.application.routes.draw do
post 'add_filter' post 'add_filter'
get 'remove_filter' => 'procedures#remove_filter', as: 'remove_filter' get 'remove_filter' => 'procedures#remove_filter', as: 'remove_filter'
get 'download_dossiers' get 'download_dossiers'
get 'stats'
get 'email_notifications' get 'email_notifications'
patch 'update_email_notifications' patch 'update_email_notifications'