From 12d8b84cfdbd05fd28a55b6813225d0ac05e54c7 Mon Sep 17 00:00:00 2001 From: aignatov-bio <47317017+aignatov-bio@users.noreply.github.com> Date: Wed, 16 Jun 2021 15:23:34 +0200 Subject: [PATCH] Fix snapshots for deleted inventory [SCI-5826] (#3393) --- app/services/reports/docx/draw_my_module.rb | 7 ++----- app/views/reports/elements/_my_module_element.html.erb | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/services/reports/docx/draw_my_module.rb b/app/services/reports/docx/draw_my_module.rb index bec2ea5ff..b15f76e9e 100644 --- a/app/services/reports/docx/draw_my_module.rb +++ b/app/services/reports/docx/draw_my_module.rb @@ -89,11 +89,8 @@ module Reports::Docx::DrawMyModule end @settings['deleted_repositories']&.each do |repo| - draw_my_module_repository(nil, - my_module, - my_module.repository_snapshots - .where(parent_id: repo) - .find_by(selected: true)) + snapshot = my_module.repository_snapshots.where(parent_id: repo).find_by(selected: true) + draw_my_module_repository(nil, my_module, snapshot) if snapshot end @docx.p diff --git a/app/views/reports/elements/_my_module_element.html.erb b/app/views/reports/elements/_my_module_element.html.erb index f9651be0f..d2df44cf9 100644 --- a/app/views/reports/elements/_my_module_element.html.erb +++ b/app/views/reports/elements/_my_module_element.html.erb @@ -100,7 +100,8 @@ <% end %> <% @settings['deleted_repositories']&.each do |repo| %> - <%= render partial: 'reports/elements/my_module_repository_element.html.erb', locals: { repository_snapshot: my_module.repository_snapshots.where(parent_id: repo).find_by(selected: true), export_all: export_all, my_module: my_module } %> + <% snapshot = my_module.repository_snapshots.where(parent_id: repo).find_by(selected: true) %> + <%= render partial: 'reports/elements/my_module_repository_element.html.erb', locals: { repository_snapshot: snapshot, export_all: export_all, my_module: my_module } if snapshot %> <% end %>