[Fixes #2480] Add 30-days evolution stats to the stats page
This commit is contained in:
parent
fbbee615c4
commit
00610991b7
3 changed files with 43 additions and 4 deletions
|
@ -137,3 +137,10 @@ $big-number-card-padding: 2 * $segmented-control-item-border-radius;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: $blue;
|
color: $blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.big-number-card-detail {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
color: $blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ class StatsController < ApplicationController
|
||||||
procedures = Procedure.publiees_ou_archivees
|
procedures = Procedure.publiees_ou_archivees
|
||||||
dossiers = Dossier.where.not(:state => :brouillon)
|
dossiers = Dossier.where.not(:state => :brouillon)
|
||||||
|
|
||||||
@procedures_count = procedures.count
|
@procedures_numbers = procedures_numbers(procedures)
|
||||||
@dossiers_count = dossiers.count
|
@dossiers_numbers = dossiers_numbers(dossiers)
|
||||||
|
|
||||||
@satisfaction_usagers = satisfaction_usagers
|
@satisfaction_usagers = satisfaction_usagers
|
||||||
@dossiers_states = dossiers_states
|
@dossiers_states = dossiers_states
|
||||||
|
@ -78,6 +78,34 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def procedures_numbers(procedures)
|
||||||
|
total = procedures.count
|
||||||
|
last_30_days_count = procedures.where(published_at: 1.month.ago..Time.now).count
|
||||||
|
previous_count = procedures.where(published_at: 2.months.ago..1.month.ago).count
|
||||||
|
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0)
|
||||||
|
formatted_evolution = sprintf("%+d", evolution)
|
||||||
|
|
||||||
|
{
|
||||||
|
total: total.to_s,
|
||||||
|
last_30_days_count: last_30_days_count.to_s,
|
||||||
|
evolution: formatted_evolution
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def dossiers_numbers(dossiers)
|
||||||
|
total = dossiers.count
|
||||||
|
last_30_days_count = dossiers.where(en_construction_at: 1.month.ago..Time.now).count
|
||||||
|
previous_count = dossiers.where(en_construction_at: 2.months.ago..1.month.ago).count
|
||||||
|
evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0)
|
||||||
|
formatted_evolution = sprintf("%+d", evolution)
|
||||||
|
|
||||||
|
{
|
||||||
|
total: total.to_s,
|
||||||
|
last_30_days_count: last_30_days_count.to_s,
|
||||||
|
evolution: formatted_evolution
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def dossiers_states
|
def dossiers_states
|
||||||
{
|
{
|
||||||
'Brouilllon' => Dossier.state_brouillon.count,
|
'Brouilllon' => Dossier.state_brouillon.count,
|
||||||
|
|
|
@ -8,12 +8,16 @@
|
||||||
.stat-card.stat-card-half.big-number-card.pull-left
|
.stat-card.stat-card-half.big-number-card.pull-left
|
||||||
%span.big-number-card-title TOTAL PROCÉDURES DÉMATÉRIALISÉES
|
%span.big-number-card-title TOTAL PROCÉDURES DÉMATÉRIALISÉES
|
||||||
%span.big-number-card-number
|
%span.big-number-card-number
|
||||||
= number_with_delimiter(@procedures_count)
|
= number_with_delimiter(@procedures_numbers[:total])
|
||||||
|
%span.big-number-card-detail
|
||||||
|
#{number_with_delimiter(@procedures_numbers[:last_30_days_count])} (#{@procedures_numbers[:evolution]} %) sur les 30 derniers jours
|
||||||
|
|
||||||
.stat-card.stat-card-half.big-number-card.pull-left
|
.stat-card.stat-card-half.big-number-card.pull-left
|
||||||
%span.big-number-card-title TOTAL DOSSIERS DÉPOSÉS
|
%span.big-number-card-title TOTAL DOSSIERS DÉPOSÉS
|
||||||
%span.big-number-card-number
|
%span.big-number-card-number
|
||||||
= number_with_delimiter(@dossiers_count)
|
= number_with_delimiter(@dossiers_numbers[:total])
|
||||||
|
%span.big-number-card-detail
|
||||||
|
#{number_with_delimiter(@dossiers_numbers[:last_30_days_count])} (#{@dossiers_numbers[:evolution]} %) sur les 30 derniers jours
|
||||||
|
|
||||||
.stat-card.stat-card-half.pull-left
|
.stat-card.stat-card-half.pull-left
|
||||||
%span.stat-card-title
|
%span.stat-card-title
|
||||||
|
|
Loading…
Reference in a new issue