Add Dossier#mean_traitement_time for the upcoming page de garde

This commit is contained in:
gregoirenovel 2018-09-18 17:50:05 +02:00
parent f3a257d81d
commit 6b98c36dad

View file

@ -326,6 +326,17 @@ class Procedure < ApplicationRecord
end end
end end
def mean_traitement_time
traitement_times = dossiers
.state_termine
.pluck(:en_construction_at, :processed_at)
.map { |times| times[1] - times[0] }
if traitement_times.present?
traitement_times.sum.fdiv(traitement_times.size).ceil
end
end
def mean_verification_time def mean_verification_time
verification_times = dossiers verification_times = dossiers
.state_termine .state_termine