fix(dossier): fix and optimize dossier projection service
This commit is contained in:
parent
5d61444852
commit
2bc076e1fb
1 changed files with 2 additions and 3 deletions
|
@ -56,12 +56,11 @@ class DossierProjectionService
|
||||||
case table
|
case table
|
||||||
when 'type_de_champ', 'type_de_champ_private'
|
when 'type_de_champ', 'type_de_champ_private'
|
||||||
Champ
|
Champ
|
||||||
.includes(:type_de_champ)
|
|
||||||
.where(
|
.where(
|
||||||
types_de_champ: { stable_id: fields.map { |f| f[COLUMN] } },
|
stable_id: fields.map { |f| f[COLUMN] },
|
||||||
dossier_id: dossiers_ids
|
dossier_id: dossiers_ids
|
||||||
)
|
)
|
||||||
.select(:dossier_id, :value, :type_de_champ_id, 'types_de_champ.stable_id', :type, :external_id, :data, :value_json) # we cannot pluck :value, as we need the champ.to_s method
|
.select(:dossier_id, :value, :stable_id, :type, :external_id, :data, :value_json) # we cannot pluck :value, as we need the champ.to_s method
|
||||||
.group_by(&:stable_id) # the champs are redispatched to their respective fields
|
.group_by(&:stable_id) # the champs are redispatched to their respective fields
|
||||||
.map do |stable_id, champs|
|
.map do |stable_id, champs|
|
||||||
field = fields.find { |f| f[COLUMN] == stable_id.to_s }
|
field = fields.find { |f| f[COLUMN] == stable_id.to_s }
|
||||||
|
|
Loading…
Reference in a new issue