return nil when no traitement time
This commit is contained in:
parent
887c5cb4a9
commit
896190b91e
2 changed files with 10 additions and 5 deletions
|
@ -67,16 +67,21 @@ module ProcedureStatsConcern
|
||||||
.group_by { |t| t[:processed_at].beginning_of_month }
|
.group_by { |t| t[:processed_at].beginning_of_month }
|
||||||
.transform_values { |month| month.map { |h| h[:processed_at] - h[:en_construction_at] } }
|
.transform_values { |month| month.map { |h| h[:processed_at] - h[:en_construction_at] } }
|
||||||
.transform_values { |traitement_times_for_month| traitement_times_for_month.percentile(PERCENTILE).ceil }
|
.transform_values { |traitement_times_for_month| traitement_times_for_month.percentile(PERCENTILE).ceil }
|
||||||
|
.transform_values { |seconds| seconds == 0 ? nil : seconds }
|
||||||
.transform_values { |seconds| convert_seconds_in_days(seconds) }
|
.transform_values { |seconds| convert_seconds_in_days(seconds) }
|
||||||
.transform_keys { |month| pretty_month(month) }
|
.transform_keys { |month| pretty_month(month) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def usual_traitement_time_for_recent_dossiers(nb_days)
|
def usual_traitement_time_for_recent_dossiers(nb_days)
|
||||||
now = Time.zone.now
|
now = Time.zone.now
|
||||||
traitement_times((now - nb_days.days)..now)
|
traitement_time =
|
||||||
.map { |times| times[:processed_at] - times[:en_construction_at] }
|
traitement_times((now - nb_days.days)..now)
|
||||||
.percentile(PERCENTILE)
|
.map { |times| times[:processed_at] - times[:en_construction_at] }
|
||||||
.ceil
|
.percentile(PERCENTILE)
|
||||||
|
.ceil
|
||||||
|
|
||||||
|
traitement_time = nil if traitement_time == 0
|
||||||
|
traitement_time
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -45,7 +45,7 @@ describe ProcedureStatsConcern do
|
||||||
|
|
||||||
context 'where there is no processed dossier' do
|
context 'where there is no processed dossier' do
|
||||||
let(:delays) { [] }
|
let(:delays) { [] }
|
||||||
it { expect(procedure.usual_traitement_time_for_recent_dossiers(30)).to eq 0 }
|
it { expect(procedure.usual_traitement_time_for_recent_dossiers(30)).to eq nil }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue