Merge pull request #2616 from betagouv/show-instruction-time
Show instruction time
This commit is contained in:
commit
c98ec1c746
5 changed files with 63 additions and 4 deletions
|
@ -326,6 +326,18 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def mean_traitement_time
|
||||
mean_time(:en_construction_at, :processed_at)
|
||||
end
|
||||
|
||||
def mean_verification_time
|
||||
mean_time(:en_construction_at, :en_instruction_at)
|
||||
end
|
||||
|
||||
def mean_instruction_time
|
||||
mean_time(:en_instruction_at, :processed_at)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def can_publish?(path)
|
||||
|
@ -388,4 +400,15 @@ class Procedure < ApplicationRecord
|
|||
self.durees_conservation_required ||= duree_conservation_dossiers_hors_ds.present? && duree_conservation_dossiers_dans_ds.present?
|
||||
true
|
||||
end
|
||||
|
||||
def mean_time(start_attribute, end_attribute)
|
||||
times = dossiers
|
||||
.state_termine
|
||||
.pluck(start_attribute, end_attribute)
|
||||
.map { |times| times[1] - times[0] }
|
||||
|
||||
if times.present?
|
||||
times.sum.fdiv(times.size).ceil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
= succeed '.' do
|
||||
%strong votre dossier passera directement en instruction
|
||||
|
||||
- if dossier.procedure.mean_verification_time
|
||||
- cache(dossier.procedure, expires_in: 1.week) do
|
||||
%p
|
||||
Le temps moyen de vérification pour cette démarche est de #{distance_of_time_in_words(dossier.procedure.mean_verification_time)}.
|
||||
|
||||
- elsif dossier.en_instruction?
|
||||
.en-instruction
|
||||
%p Votre dossier est complet. Il est en cours d’examen par les instructeur de l’administration.
|
||||
|
@ -34,6 +39,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,34 @@ 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 construction" do
|
||||
before do
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: simple_procedure, en_construction_at: 10.days.ago, en_instruction_at: Time.now)
|
||||
end
|
||||
|
||||
it "show the proper wait time" do
|
||||
visit_dossier dossier
|
||||
|
||||
expect(page).to have_text("Le temps moyen de vérification pour cette démarche est de 10 jours.")
|
||||
end
|
||||
end
|
||||
|
||||
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…
Reference in a new issue