Skip to content

Commit

Permalink
Fixes #38058 - Fix applied errata report
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka authored and sbernhard committed Dec 4, 2024
1 parent c79f9b1 commit 7655a15
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/lib/katello/concerns/base_template_scope_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,16 @@ def load_errata_applications(filter_errata_type: nil, include_last_reboot: 'yes'
search_since = since.present? ? "ended_at > \"#{since}\"" : nil
search_result = status.present? && status != 'all' ? "result = #{status}" : nil
labels = 'label ^ (Actions::Katello::Host::Erratum::Install, Actions::Katello::Host::Erratum::ApplicableErrataInstall)'
select = 'foreman_tasks_tasks.*'

new_labels = 'label = Actions::RemoteExecution::RunHostJob AND remote_execution_feature.label ^ (katello_errata_install, katello_errata_install_by_search)'
labels = [labels, new_labels].map { |label| "(#{label})" }.join(' OR ')
select += ',template_invocations.id AS template_invocation_id'

search = [search_up_to, search_since, search_result, "state = stopped", labels].compact.join(' and ')

tasks = load_resource(klass: ForemanTasks::Task,
permission: 'view_foreman_tasks',
select: select,
joins: [:template_invocation],
preload: [:template_invocation],
search: search)
only_host_ids = ::Host.search_for(host_filter).pluck(:id) if host_filter

Expand Down Expand Up @@ -383,7 +382,7 @@ def errata_ids_from_template_invocation(task, task_input)
found = script.lines.find { |line| line.start_with? '# RESOLVED_ERRATA_IDS=' } || ''
(found.chomp.split('=', 2).last || '').split(',')
else
TemplateInvocationInputValue.joins(:template_input).where("template_invocation_id = ? AND template_inputs.name = ?", task.template_invocation_id, 'errata')
TemplateInvocationInputValue.joins(:template_input).where("template_invocation_id = ? AND template_inputs.name = ?", task.template_invocation.id, 'errata')
.first&.value&.split(',') || []
end
end
Expand Down

2 comments on commit 7655a15

@dotcomstar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 thank you, you beat me to it. Is there any way you can package this into a new release version soon?

@sbernhard
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.