mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 04:31:21 -03:30
switching to iterator and adding the missed Job cleanup
Signed-off-by: Mike McMahon <mike.mcmahon@wavefront.com>
This commit is contained in:
parent
023431165a
commit
399e0e5e24
@ -65,7 +65,8 @@ class Command(NoArgsCommand):
|
||||
#jobs_qs = Job.objects.exclude(status__in=('pending', 'running'))
|
||||
#jobs_qs = jobs_qs.filter(created__lte=self.cutoff)
|
||||
skipped, deleted = 0, 0
|
||||
for job in Job.objects.all():
|
||||
jobs = Job.objects.filter(created__lte=self.cutoff)
|
||||
for job in jobs.iterator():
|
||||
job_display = '"%s" (%d host summaries, %d events)' % \
|
||||
(unicode(job),
|
||||
job.job_host_summaries.count(), job.job_events.count())
|
||||
@ -88,7 +89,7 @@ class Command(NoArgsCommand):
|
||||
def cleanup_ad_hoc_commands(self):
|
||||
skipped, deleted = 0, 0
|
||||
ad_hoc_commands = AdHocCommand.objects.filter(created__lte=self.cutoff)
|
||||
for ad_hoc_command in ad_hoc_commands:
|
||||
for ad_hoc_command in ad_hoc_commands.iterator():
|
||||
ad_hoc_command_display = '"%s" (%d events)' % \
|
||||
(unicode(ad_hoc_command),
|
||||
ad_hoc_command.ad_hoc_command_events.count())
|
||||
@ -111,7 +112,7 @@ class Command(NoArgsCommand):
|
||||
def cleanup_project_updates(self):
|
||||
skipped, deleted = 0, 0
|
||||
project_updates = ProjectUpdate.objects.filter(created__lte=self.cutoff)
|
||||
for pu in project_updates:
|
||||
for pu in project_updates.iterator():
|
||||
pu_display = '"%s" (type %s)' % (unicode(pu), unicode(pu.launch_type))
|
||||
if pu.status in ('pending', 'waiting', 'running'):
|
||||
action_text = 'would skip' if self.dry_run else 'skipping'
|
||||
@ -136,7 +137,7 @@ class Command(NoArgsCommand):
|
||||
def cleanup_inventory_updates(self):
|
||||
skipped, deleted = 0, 0
|
||||
inventory_updates = InventoryUpdate.objects.filter(created__lte=self.cutoff)
|
||||
for iu in inventory_updates:
|
||||
for iu in inventory_updates.iterator():
|
||||
iu_display = '"%s" (source %s)' % (unicode(iu), unicode(iu.source))
|
||||
if iu.status in ('pending', 'waiting', 'running'):
|
||||
action_text = 'would skip' if self.dry_run else 'skipping'
|
||||
@ -161,7 +162,7 @@ class Command(NoArgsCommand):
|
||||
def cleanup_management_jobs(self):
|
||||
skipped, deleted = 0, 0
|
||||
system_jobs = SystemJob.objects.filter(created__lte=self.cutoff)
|
||||
for sj in system_jobs:
|
||||
for sj in system_jobs.iterator():
|
||||
sj_display = '"%s" (type %s)' % (unicode(sj), unicode(sj.job_type))
|
||||
if sj.status in ('pending', 'waiting', 'running'):
|
||||
action_text = 'would skip' if self.dry_run else 'skipping'
|
||||
@ -192,7 +193,7 @@ class Command(NoArgsCommand):
|
||||
def cleanup_workflow_jobs(self):
|
||||
skipped, deleted = 0, 0
|
||||
workflow_jobs = WorkflowJob.objects.filter(created__lte=self.cutoff)
|
||||
for workflow_job in workflow_jobs:
|
||||
for workflow_job in workflow_jobs.iterator():
|
||||
workflow_job_display = '"{}" ({} nodes)'.format(
|
||||
unicode(workflow_job),
|
||||
workflow_job.workflow_nodes.count())
|
||||
@ -215,7 +216,7 @@ class Command(NoArgsCommand):
|
||||
def cleanup_notifications(self):
|
||||
skipped, deleted = 0, 0
|
||||
notifications = Notification.objects.filter(created__lte=self.cutoff)
|
||||
for notification in notifications:
|
||||
for notification in notifications.iterator():
|
||||
notification_display = '"{}" (started {}, {} type, {} sent)'.format(
|
||||
unicode(notification), unicode(notification.created),
|
||||
notification.notification_type, notification.notifications_sent)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user