From 701a28302ecc6207b82b0355b7ce8015aadaf546 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 22 Aug 2024 17:31:36 +0200 Subject: [PATCH] refactor(dossier): remove unused scopes --- app/models/dossier.rb | 33 ++++++++------------------------- app/models/procedure.rb | 14 -------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 2ef0ce57f..2227a58e2 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -270,33 +270,16 @@ class Dossier < ApplicationRecord scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } scope :without_followers, -> { where.missing(:follows) } scope :with_followers, -> { left_outer_joins(:follows).where.not(follows: { id: nil }) } - scope :with_champs, -> { - includes(champs_public: [ - :geo_areas, - piece_justificative_file_attachments: :blob, - champs: [piece_justificative_file_attachments: :blob] - ]) - } - scope :brouillons_recently_updated, -> { updated_since(2.days.ago).state_brouillon.order_by_updated_at } - scope :with_annotations, -> { - includes(champs_private: [ - :geo_areas, - piece_justificative_file_attachments: :blob, - champs: [piece_justificative_file_attachments: :blob] - ]) - } scope :for_api, -> { - with_champs - .with_annotations - .includes(commentaires: { piece_jointe_attachments: :blob }, - justificatif_motivation_attachment: :blob, - attestation: [], - avis: { piece_justificative_file_attachment: :blob }, - traitement: [], - etablissement: [], - individual: [], - user: []) + includes(commentaires: { piece_jointe_attachments: :blob }, + justificatif_motivation_attachment: :blob, + attestation: [], + avis: { piece_justificative_file_attachment: :blob }, + traitement: [], + etablissement: [], + individual: [], + user: []) } scope :with_notifiable_procedure, -> (opts = { notify_on_closed: false }) do diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 43512a928..ae167b266 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -239,20 +239,6 @@ class Procedure < ApplicationRecord includes(:draft_revision, :published_revision, administrateurs: :user) } - scope :for_download, -> { - includes( - :groupe_instructeurs, - dossiers: { - champs_public: [ - piece_justificative_file_attachments: :blob, - champs: [ - piece_justificative_file_attachments: :blob - ] - ] - } - ) - } - validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false validates :administrateurs, presence: true