Merge pull request #6285 from betagouv/6207-fix-count-archives
archives: count archived dossiers
This commit is contained in:
commit
f64dedc872
2 changed files with 9 additions and 2 deletions
|
@ -29,7 +29,7 @@ class Traitement < ApplicationRecord
|
||||||
def self.count_dossiers_termines_by_month(groupe_instructeurs)
|
def self.count_dossiers_termines_by_month(groupe_instructeurs)
|
||||||
last_traitements_per_dossier = Traitement
|
last_traitements_per_dossier = Traitement
|
||||||
.select('max(traitements.processed_at) as processed_at')
|
.select('max(traitements.processed_at) as processed_at')
|
||||||
.where(dossier: Dossier.termine.where(groupe_instructeur: groupe_instructeurs))
|
.where(dossier: Dossier.state_termine.where(groupe_instructeur: groupe_instructeurs))
|
||||||
.group(:dossier_id)
|
.group(:dossier_id)
|
||||||
.to_sql
|
.to_sql
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe Traitement do
|
||||||
before do
|
before do
|
||||||
create_dossier_for_month(procedure, 2021, 3)
|
create_dossier_for_month(procedure, 2021, 3)
|
||||||
create_dossier_for_month(procedure, 2021, 3)
|
create_dossier_for_month(procedure, 2021, 3)
|
||||||
|
create_archived_dossier_for_month(procedure, 2021, 3)
|
||||||
create_dossier_for_month(procedure, 2021, 2)
|
create_dossier_for_month(procedure, 2021, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ describe Traitement do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'count dossiers_termines by month' do
|
it 'count dossiers_termines by month' do
|
||||||
expect(count_for_month(subject, 3)).to eq 2
|
expect(count_for_month(subject, 3)).to eq 3
|
||||||
expect(count_for_month(subject, 2)).to eq 1
|
expect(count_for_month(subject, 2)).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,4 +40,10 @@ describe Traitement do
|
||||||
create(:dossier, :accepte, :with_attestation, procedure: procedure)
|
create(:dossier, :accepte, :with_attestation, procedure: procedure)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_archived_dossier_for_month(procedure, year, month)
|
||||||
|
Timecop.freeze(Time.zone.local(year, month, 5)) do
|
||||||
|
create(:dossier, :accepte, :archived, :with_attestation, procedure: procedure)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue