From fd08bb8c577e83bde6c8555428bc424d801a95f8 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 10 Oct 2017 15:30:57 +0200 Subject: [PATCH] Eager-load data for downloadable dossiers So that the export is faster --- app/models/dossier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 5e7cc545a..32541d571 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -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 }) }