Show the mean instruction time in the Résumé tab
This commit is contained in:
parent
faff741bf2
commit
d55c9dff4d
5 changed files with 34 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
%strong
|
||||
vous recevrez un email
|
||||
avec le résultat.
|
||||
- if dossier.procedure.mean_instruction_time
|
||||
- cache(dossier.procedure, expires_in: 1.week) do
|
||||
%p
|
||||
Le temps moyen d’instruction pour cette démarche est de #{distance_of_time_in_words(dossier.procedure.mean_instruction_time)}.
|
||||
|
||||
- elsif dossier.accepte?
|
||||
.accepte
|
||||
|
|
|
@ -47,7 +47,6 @@ fr:
|
|||
submit:
|
||||
publish: Publier
|
||||
reopen: Réactiver
|
||||
|
||||
support:
|
||||
info demarche: J'ai un problème lors du remplissage de mon dossier
|
||||
info instruction: J'ai une question sur l'instruction de mon dossier
|
||||
|
|
|
@ -97,9 +97,9 @@ FactoryBot.define do
|
|||
trait :accepte do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = Dossier.states.fetch(:accepte)
|
||||
dossier.processed_at = dossier.created_at + 1.minute
|
||||
dossier.en_construction_at = dossier.created_at + 2.minutes
|
||||
dossier.created_at = dossier.created_at + 3.minutes
|
||||
dossier.processed_at ||= dossier.created_at + 1.minute
|
||||
dossier.en_construction_at ||= dossier.created_at + 2.minutes
|
||||
dossier.created_at ||= dossier.created_at + 3.minutes
|
||||
dossier.save!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,22 @@ describe 'Dossier details:' do
|
|||
expect(page).to have_text(dossier.commentaires.last.body)
|
||||
end
|
||||
|
||||
describe "the user can see the mean time they are expected to wait" do
|
||||
context "the dossier is in instruction" do
|
||||
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: simple_procedure) }
|
||||
|
||||
before do
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: simple_procedure, en_instruction_at: 2.months.ago, processed_at: Time.now)
|
||||
end
|
||||
|
||||
it "show the proper wait time" do
|
||||
visit_dossier dossier
|
||||
|
||||
expect(page).to have_text("Le temps moyen d’instruction pour cette démarche est de 2 mois.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'the user can see and edit dossier before instruction' do
|
||||
visit_dossier dossier
|
||||
click_on 'Demande'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue