Eager-load data for downloadable dossiers

So that the export is faster
This commit is contained in:
gregoirenovel 2017-10-10 15:30:57 +02:00
parent 8125c7265a
commit fd08bb8c57

View file

@ -58,7 +58,7 @@ class Dossier < ActiveRecord::Base
scope :nouveaux, -> { not_archived.state_nouveaux }
scope :en_instruction, -> { not_archived.state_en_instruction }
scope :termine, -> { not_archived.state_termine }
scope :downloadable, -> { state_not_brouillon }
scope :downloadable, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private) }
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
scope :without_followers, -> { includes(:follows).where(follows: { id: nil }) }
scope :with_unread_notifications, -> { where(notifications: { already_read: false }) }