Merge pull request #8270 from tchak/fix-improuve-batch-dossiers-query

refactor(dossier): improuve dossiers_safe_scope on batch operation
This commit is contained in:
Paul Chavard 2022-12-14 10:01:23 +01:00 committed by GitHub
commit b740c75f09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,10 +40,10 @@ class BatchOperation < ApplicationRecord
} }
def dossiers_safe_scope(dossier_ids = self.dossier_ids) def dossiers_safe_scope(dossier_ids = self.dossier_ids)
query = Dossier.joins(:procedure) query = instructeur
.where(procedure: { id: instructeur.procedures.ids }) .dossiers
.where(id: dossier_ids)
.visible_by_administration .visible_by_administration
.where(id: dossier_ids)
case operation case operation
when BatchOperation.operations.fetch(:archiver) then when BatchOperation.operations.fetch(:archiver) then
query.not_archived.state_termine query.not_archived.state_termine