Fix the cleanup_jobs management command

It previously depended on a private Django internal class that changed
with Django 3.1.

I've switched here instead to disabling the django-polymorphic
accessors to get the underlying UnifiedJob object for a Job, which due
to the way they implement those was resulting in N+1 behavior on
deletes.  This gets us back most of the way to the performance gains
we achieved with the custom collector class.  See
https://github.com/django-polymorphic/django-polymorphic/issues/198.
This commit is contained in:
Jeff Bradberry
2022-02-10 14:00:11 -05:00
parent 0500512c3c
commit 028f09002f
5 changed files with 62 additions and 410 deletions

View File

@@ -318,8 +318,9 @@ if __name__ == '__main__':
for j_hour in range(24):
time_delta = datetime.timedelta(days=i_day, hours=j_hour, seconds=0)
created_job_ids = generate_jobs(jobs, batch_size=batch_size, time_delta=time_delta)
for k_id in created_job_ids:
generate_events(events, str(k_id), time_delta)
if events > 0:
for k_id in created_job_ids:
generate_events(events, str(k_id), time_delta)
print(datetime.datetime.utcnow().isoformat())
conn.close()