[#3477] Introduce column variable

This commit is contained in:
Frederic Merizen 2019-02-26 16:13:22 +01:00 committed by Frederic Merizen
parent 35d5322a9b
commit 55d4dcc174

View file

@ -102,7 +102,7 @@ class ProcedurePresentation < ApplicationRecord
def filtered_ids(dossiers, statut)
dossiers.each { |dossier| assert_matching_procedure(dossier) }
filters[statut].group_by { |filter| filter.slice('table', 'column') } .map do |field, filters|
table = field['table']
table, column = field.values_at('table', 'column')
table_column = sanitized_column(field)
values = filters.pluck('value')
case table
@ -116,10 +116,10 @@ class ProcedurePresentation < ApplicationRecord
Filter.new(
dossiers
.includes(relation)
.where("champs.type_de_champ_id = ?", field['column'].to_i)
.where("champs.type_de_champ_id = ?", column.to_i)
).where_ilike('champs.value', values)
when 'etablissement'
if field['column'] == 'entreprise_date_creation'
if column == 'entreprise_date_creation'
dates = values.map { |v| v.to_date rescue nil }
Filter.new(
dossiers.includes(table)