Module: ForemanRemoteExecution::JobInvocationCleaner
- Defined in:
- app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb
Instance Method Summary collapse
- #delete ⇒ Object
- #delete_job_invocations(tasks) ⇒ Object
- #delete_tasks(chunk) ⇒ Object
- #orphaned_job_invocations ⇒ Object
Instance Method Details
#delete ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 11 def delete super with_noop(orphaned_job_invocations, 'orphaned job invocations') do |source, name| with_batches(source, name) do |invocations| invocations.destroy_all end end end |
#delete_job_invocations(tasks) ⇒ Object
25 26 27 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 25 def delete_job_invocations(tasks) JobInvocation.where(:task_id => tasks.map(&:id)).find_each(&:destroy) end |
#delete_tasks(chunk) ⇒ Object
20 21 22 23 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 20 def delete_tasks(chunk) super(chunk) delete_job_invocations(chunk) end |
#orphaned_job_invocations ⇒ Object
29 30 31 32 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 29 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 |