Sha256: 734838367a53c40ab1b0bd5ddc5f231f6a08c2305aea06e62851d3446a64ceb1
Contents?: true
Size: 901 Bytes
Versions: 19
Compression:
Stored size: 901 Bytes
Contents
module ForemanRemoteExecution module ForemanTasksCleanerExtensions extend ActiveSupport::Concern included do prepend ForemanRemoteExecution::JobInvocationCleaner end end module JobInvocationCleaner def delete super with_noop(orphaned_job_invocations, 'oprhaned job invocations') do |source, name| with_batches(source, name) do |invocations| invocations.destroy_all end end end def delete_tasks(chunk) super(chunk) delete_job_invocations(chunk) end def delete_job_invocations(tasks) JobInvocation.where(:task_id => tasks.map(&:id)).find_each(&:destroy) end def orphaned_job_invocations JobInvocation.joins('LEFT JOIN foreman_tasks_tasks ON task_id = foreman_tasks_tasks.id') .where('task_id IS NOT NULL and foreman_tasks_tasks.id IS NULL') end end end
Version data entries
19 entries across 19 versions & 1 rubygems