Use indexed timestamps

Use created and finished, which are indexed, to try to fetch all
states of jobs. If job is not finished, we might not get the
right terminal status, but that should be ok for now.
This commit is contained in:
Ladislav Smola 2020-03-18 10:16:07 +01:00
parent 6a503e152a
commit 6a86af5b43

View File

@ -277,8 +277,8 @@ def copy_tables(since, full_path):
FROM main_unifiedjob
JOIN django_content_type ON main_unifiedjob.polymorphic_ctype_id = django_content_type.id
LEFT JOIN main_organization ON main_organization.id = main_unifiedjob.organization_id
WHERE main_unifiedjob.modified > {}
AND main_unifiedjob.launch_type != 'sync'
WHERE (main_unifiedjob.created > {0} OR main_unifiedjob.finished > {0})
AND main_unifiedjob.launch_type != 'sync'
ORDER BY main_unifiedjob.id ASC) TO STDOUT WITH CSV HEADER'''.format(since.strftime("'%Y-%m-%d %H:%M:%S'"))
_copy_table(table='unified_jobs', query=unified_job_query, path=full_path)