Show the mean instruction time in the Résumé tab

This commit is contained in:
gregoirenovel 2018-09-18 17:45:24 +02:00
parent faff741bf2
commit d55c9dff4d
5 changed files with 34 additions and 4 deletions

View file

@ -326,6 +326,17 @@ class Procedure < ApplicationRecord
end
end
def mean_instruction_time
instruction_times = dossiers
.state_termine
.pluck(:en_instruction_at, :processed_at)
.map { |times| times[1] - times[0] }
if instruction_times.present?
instruction_times.sum.fdiv(instruction_times.size).ceil
end
end
private
def can_publish?(path)