Sha256: 0202f0cf546946dde12e3f96d0628ce04cdd4aeda6b4b2ebca2cad850b30c49a
Contents?: true
Size: 1.03 KB
Versions: 12
Compression:
Stored size: 1.03 KB
Contents
module ForemanRemoteExecution module ForemanTasksCleanerExtensions extend ActiveSupport::Concern included do prepend ForemanRemoteExecution::JobInvocationCleaner end end module JobInvocationCleaner def delete super if noop say '[noop] deleting orphaned job invocations' say "[noop] #{orphaned_job_invocations.count} job invocations would be deleted" else count = orphaned_job_invocations.count orphaned_job_invocations.find_each(&:destroy) say "deleted #{count} orphaned job_invocations", false if verbose end end def delete_tasks(chunk) super(chunk) delete_job_invocations(chunk) end def delete_job_invocations(chunk) JobInvocation.where(:task_id => chunk.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
12 entries across 12 versions & 1 rubygems