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(chunk) ⇒ Object
- #delete_tasks(chunk) ⇒ Object
- #orphaned_job_invocations ⇒ Object
Instance Method Details
#delete ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 11 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 |
#delete_job_invocations(chunk) ⇒ Object
28 29 30 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 28 def delete_job_invocations(chunk) JobInvocation.where(:task_id => chunk.map(&:id)).find_each(&:destroy) end |
#delete_tasks(chunk) ⇒ Object
23 24 25 26 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 23 def delete_tasks(chunk) super(chunk) delete_job_invocations(chunk) end |
#orphaned_job_invocations ⇒ Object
32 33 34 35 |
# File 'app/models/concerns/foreman_remote_execution/foreman_tasks_cleaner_extensions.rb', line 32 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 |