mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Potential fix for pull request finding 'CodeQL / Database query in a loop'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
error_count = erroneous_results.count
|
||||
total_count = service_result.dependent_results.map(&:result).uniq.count
|
||||
selected_count = selected_work_packages.count
|
||||
selected_ids = selected_work_packages.map(&:id)
|
||||
source_ids = erroneous_results.map { |call| call.state.copied_from_work_package_id }.compact.uniq
|
||||
source_work_packages_by_id = source_ids.any? ? WorkPackage.where(id: source_ids).index_by(&:id) : {}
|
||||
%>
|
||||
|
||||
<% if total_count - error_count == 0 %>
|
||||
@@ -32,11 +35,11 @@
|
||||
<ul>
|
||||
<% erroneous_results.each do |call| %>
|
||||
<% source_id = call.state.copied_from_work_package_id %>
|
||||
<% wp = source_id ? WorkPackage.find_by(id: source_id) : call.result %>
|
||||
<% wp = source_id ? source_work_packages_by_id[source_id] : call.result %>
|
||||
<% wp_id = wp&.id || call.result.id %>
|
||||
|
||||
<li>
|
||||
<%= link_to wp&.formatted_id || "##{wp_id}", work_package_path(wp_id) %><%= selected_work_packages.map(&:id).include?(wp_id) ? "" : " (#{I18n.t('work_packages.bulk.descendant')})" %>:
|
||||
<%= link_to wp&.formatted_id || "##{wp_id}", work_package_path(wp_id) %><%= selected_ids.include?(wp_id) ? "" : " (#{I18n.t('work_packages.bulk.descendant')})" %>:
|
||||
<%= safe_join call.errors.full_messages, " " %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user