refactor: fix n+1
This commit is contained in:
parent
18a4ee450f
commit
d287eac706
3 changed files with 4 additions and 2 deletions
|
@ -896,7 +896,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def previously_termine?
|
||||
traitements.termine.exists?
|
||||
traitements.any?(&:termine?)
|
||||
end
|
||||
|
||||
def remove_titres_identite!
|
||||
|
|
|
@ -26,4 +26,6 @@ class Traitement < ApplicationRecord
|
|||
self.browser_supported = BrowserSupport.supported?(browser)
|
||||
end
|
||||
end
|
||||
|
||||
def termine? = state.in?(Dossier::TERMINE)
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class DossierProjectionService
|
|||
# - the order of the intermediary query results are unknown
|
||||
# - some values can be missing (if a revision added or removed them)
|
||||
def self.project(dossiers_ids, columns)
|
||||
dossiers = Dossier.includes(:corrections, :pending_corrections).find(dossiers_ids)
|
||||
dossiers = Dossier.includes(:corrections, :pending_corrections, :traitements).find(dossiers_ids)
|
||||
|
||||
fields = columns.map do |c|
|
||||
if c.is_a?(Columns::ChampColumn)
|
||||
|
|
Loading…
Reference in a new issue