Merge pull request #10171 from tchak/fix-perf-filters
perf(filter): we query by stable_id - no need to check type_de_champ private attribute
This commit is contained in:
commit
707d3980c0
2 changed files with 4 additions and 9 deletions
|
@ -247,12 +247,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
scope :with_type_de_champ, -> (stable_id) {
|
||||
joins('INNER JOIN champs ON champs.dossier_id = dossiers.id INNER JOIN types_de_champ ON types_de_champ.id = champs.type_de_champ_id')
|
||||
.where('types_de_champ.private = FALSE AND types_de_champ.stable_id = ?', stable_id)
|
||||
}
|
||||
|
||||
scope :with_type_de_champ_private, -> (stable_id) {
|
||||
joins('INNER JOIN champs ON champs.dossier_id = dossiers.id INNER JOIN types_de_champ ON types_de_champ.id = champs.type_de_champ_id')
|
||||
.where('types_de_champ.private = TRUE AND types_de_champ.stable_id = ?', stable_id)
|
||||
.where(types_de_champ: { stable_id: })
|
||||
}
|
||||
|
||||
scope :all_state, -> { not_archived.state_not_brouillon }
|
||||
|
|
|
@ -163,7 +163,7 @@ class ProcedurePresentation < ApplicationRecord
|
|||
end
|
||||
when TYPE_DE_CHAMP_PRIVATE
|
||||
ids = dossiers
|
||||
.with_type_de_champ_private(column)
|
||||
.with_type_de_champ(column)
|
||||
.order("champs.value #{order}")
|
||||
.pluck(:id)
|
||||
if ids.size != count
|
||||
|
@ -218,8 +218,8 @@ class ProcedurePresentation < ApplicationRecord
|
|||
dossiers.with_type_de_champ(column)
|
||||
.filter_ilike(:champs, value_column, values)
|
||||
when TYPE_DE_CHAMP_PRIVATE
|
||||
dossiers.with_type_de_champ_private(column)
|
||||
.filter_ilike(:champs_private, value_column, values)
|
||||
dossiers.with_type_de_champ(column)
|
||||
.filter_ilike(:champs, value_column, values)
|
||||
when 'etablissement'
|
||||
if column == 'entreprise_date_creation'
|
||||
dates = values
|
||||
|
|
Loading…
Reference in a new issue