perf(zip): give champ to avoid seeking stable_id
This commit is contained in:
parent
a7e29c4ea6
commit
ca12a56e6a
1 changed files with 6 additions and 7 deletions
|
@ -45,10 +45,10 @@ class ExportTemplate < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attachment_and_path(dossier, attachment, index: 0, row_index: nil)
|
def attachment_and_path(dossier, attachment, index: 0, row_index: nil, champ: nil)
|
||||||
[
|
[
|
||||||
attachment,
|
attachment,
|
||||||
path(dossier, attachment, index, row_index)
|
path(dossier, attachment, index, row_index, champ)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class ExportTemplate < ApplicationRecord
|
||||||
"#{render_attributes_for(content["pdf_name"], dossier)}.pdf"
|
"#{render_attributes_for(content["pdf_name"], dossier)}.pdf"
|
||||||
end
|
end
|
||||||
|
|
||||||
def path(dossier, attachment, index, row_index)
|
def path(dossier, attachment, index, row_index, champ)
|
||||||
if attachment.name == 'pdf_export_for_instructeur'
|
if attachment.name == 'pdf_export_for_instructeur'
|
||||||
return export_path(dossier)
|
return export_path(dossier)
|
||||||
end
|
end
|
||||||
|
@ -130,15 +130,14 @@ class ExportTemplate < ApplicationRecord
|
||||||
'avis'
|
'avis'
|
||||||
else
|
else
|
||||||
# for attachment
|
# for attachment
|
||||||
return attachment_path(dossier, attachment, index, row_index)
|
return attachment_path(dossier, attachment, index, row_index, champ)
|
||||||
end
|
end
|
||||||
|
|
||||||
File.join(folder(dossier), dir_path, attachment.filename.to_s)
|
File.join(folder(dossier), dir_path, attachment.filename.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def attachment_path(dossier, attachment, index, row_index)
|
def attachment_path(dossier, attachment, index, row_index, champ)
|
||||||
type_de_champ_id = dossier.champs.find(attachment.record_id).type_de_champ_id
|
stable_id = champ.stable_id
|
||||||
stable_id = TypeDeChamp.find(type_de_champ_id).stable_id
|
|
||||||
tiptap_pj = content["pjs"].find { |pj| pj["stable_id"] == stable_id.to_s }
|
tiptap_pj = content["pjs"].find { |pj| pj["stable_id"] == stable_id.to_s }
|
||||||
if tiptap_pj
|
if tiptap_pj
|
||||||
File.join(folder(dossier), tiptap_convert_pj(dossier, stable_id, attachment) + suffix(attachment, index, row_index))
|
File.join(folder(dossier), tiptap_convert_pj(dossier, stable_id, attachment) + suffix(attachment, index, row_index))
|
||||||
|
|
Loading…
Add table
Reference in a new issue