[Fix #264] Add pie chart to count administrations
This commit is contained in:
parent
cdb6240ca8
commit
69a5857322
3 changed files with 56 additions and 0 deletions
|
@ -16,6 +16,8 @@ class StatsController < ApplicationController
|
||||||
@dossiers_cumulative = cumulative_hash(dossiers, :initiated_at)
|
@dossiers_cumulative = cumulative_hash(dossiers, :initiated_at)
|
||||||
@dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :initiated_at)
|
@dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :initiated_at)
|
||||||
|
|
||||||
|
@procedures_count_per_administrateur = procedures_count_per_administrateur(procedures)
|
||||||
|
|
||||||
@dossier_instruction_mean_time = dossier_instruction_mean_time(dossiers)
|
@dossier_instruction_mean_time = dossier_instruction_mean_time(dossiers)
|
||||||
@dossier_filling_mean_time = dossier_filling_mean_time(dossiers)
|
@dossier_filling_mean_time = dossier_filling_mean_time(dossiers)
|
||||||
end
|
end
|
||||||
|
@ -46,6 +48,15 @@ class StatsController < ApplicationController
|
||||||
.reduce({}, :merge)
|
.reduce({}, :merge)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def procedures_count_per_administrateur(procedures)
|
||||||
|
count_per_administrateur = procedures.group(:administrateur_id).count.values
|
||||||
|
{
|
||||||
|
'Une procédure' => count_per_administrateur.select { |count| count == 1 }.count,
|
||||||
|
'Entre deux et cinq procédures' => count_per_administrateur.select { |count| 2 <= count && count <= 5 }.count,
|
||||||
|
'Plus de cinq procédures' => count_per_administrateur.select { |count| 5 < count }.count
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def mean(collection)
|
def mean(collection)
|
||||||
(collection.sum.to_f / collection.size).round(2)
|
(collection.sum.to_f / collection.size).round(2)
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,6 +47,15 @@
|
||||||
= area_chart @dossiers_cumulative,
|
= area_chart @dossiers_cumulative,
|
||||||
:colors => ["rgba(61, 149, 236, 1)"]
|
:colors => ["rgba(61, 149, 236, 1)"]
|
||||||
|
|
||||||
|
.stat-card.stat-card-half.pull-left
|
||||||
|
%span.stat-card-title
|
||||||
|
Nombre d'administrations ayant dématérialisé N procédures
|
||||||
|
|
||||||
|
.chart-container
|
||||||
|
.chart
|
||||||
|
= pie_chart @procedures_count_per_administrateur,
|
||||||
|
:colors => ["rgba(191, 220, 249, 1)", "rgba(113, 176, 239, 1)", "rgba(61, 149, 236, 1)"]
|
||||||
|
|
||||||
- if administration_signed_in?
|
- if administration_signed_in?
|
||||||
- cache "computation-heavy-stats", :expires_in => 1.day do
|
- cache "computation-heavy-stats", :expires_in => 1.day do
|
||||||
.stat-card.stat-card-half.pull-left
|
.stat-card.stat-card-half.pull-left
|
||||||
|
|
|
@ -75,6 +75,42 @@ describe StatsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#procedures_count_per_administrateur" do
|
||||||
|
let!(:administrateur_1) { create(:administrateur) }
|
||||||
|
let!(:administrateur_2) { create(:administrateur) }
|
||||||
|
let!(:administrateur_3) { create(:administrateur) }
|
||||||
|
let!(:administrateur_4) { create(:administrateur) }
|
||||||
|
let!(:administrateur_5) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
3.times do
|
||||||
|
create(:procedure, published: true, administrateur: administrateur_1)
|
||||||
|
end
|
||||||
|
|
||||||
|
2.times do
|
||||||
|
create(:procedure, published: true, administrateur: administrateur_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
8.times do
|
||||||
|
create(:procedure, published: true, administrateur: administrateur_3)
|
||||||
|
end
|
||||||
|
|
||||||
|
create(:procedure, published: true, administrateur: administrateur_4)
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:association){ Procedure.all }
|
||||||
|
|
||||||
|
subject { StatsController.new.send(:procedures_count_per_administrateur, association) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
is_expected.to eq({
|
||||||
|
'Une procédure' => 1,
|
||||||
|
'Entre deux et cinq procédures' => 2,
|
||||||
|
'Plus de cinq procédures' => 1
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#dossier_instruction_mean_time" do
|
describe "#dossier_instruction_mean_time" do
|
||||||
# Month-2: mean 3 days
|
# Month-2: mean 3 days
|
||||||
# procedure_1: mean 2 days
|
# procedure_1: mean 2 days
|
||||||
|
|
Loading…
Reference in a new issue