[#3477] Better choice of case vs if
This commit is contained in:
parent
66fa7ef11d
commit
c81adb80fd
1 changed files with 5 additions and 5 deletions
|
@ -245,14 +245,16 @@ module NewGestionnaire
|
||||||
procedure_presentation.displayed_fields
|
procedure_presentation.displayed_fields
|
||||||
.reject { |field| field['table'] == 'self' }
|
.reject { |field| field['table'] == 'self' }
|
||||||
.group_by do |field|
|
.group_by do |field|
|
||||||
if ['type_de_champ', 'type_de_champ_private'].include?(field['table'])
|
case field['table']
|
||||||
|
when 'type_de_champ', 'type_de_champ_private'
|
||||||
'type_de_champ_group'
|
'type_de_champ_group'
|
||||||
else
|
else
|
||||||
field['table']
|
field['table']
|
||||||
end
|
end
|
||||||
end.reduce(dossiers) do |dossiers, (group_key, fields)|
|
end.reduce(dossiers) do |dossiers, (group_key, fields)|
|
||||||
case group_key
|
if group_key != 'type_de_champ_group'
|
||||||
when 'type_de_champ_group'
|
dossiers.includes(fields.first['table'])
|
||||||
|
else
|
||||||
if fields.any? { |field| field['table'] == 'type_de_champ' }
|
if fields.any? { |field| field['table'] == 'type_de_champ' }
|
||||||
dossiers = dossiers.includes(:champs).references(:champs)
|
dossiers = dossiers.includes(:champs).references(:champs)
|
||||||
end
|
end
|
||||||
|
@ -266,8 +268,6 @@ module NewGestionnaire
|
||||||
end.join(" OR ")
|
end.join(" OR ")
|
||||||
|
|
||||||
dossiers.where(where_conditions)
|
dossiers.where(where_conditions)
|
||||||
else
|
|
||||||
dossiers.includes(fields.first['table'])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue