summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-09-15 00:55:47 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-09-15 01:59:44 +0100
commita42dda78aeb266f9f75a2303e6113c707f78907b (patch)
treeebfada5ab066635f1a6b2173efbec44e7139f55c
parent031cb3b6cbf52cd0becd9fdad0facc6c34c083af (diff)
downloadlorry-controller-a42dda78aeb266f9f75a2303e6113c707f78907b.tar.gz
lorry-controller-remove-old-jobs: Add start time to JobInfo class
In order to filter jobs more efficiently, we need to look at the start time (job_started in the API) as well as the finish time. Related to #18.
-rwxr-xr-xlorry-controller-remove-old-jobs11
1 files changed, 7 insertions, 4 deletions
diff --git a/lorry-controller-remove-old-jobs b/lorry-controller-remove-old-jobs
index 677e0cd..94ad71b 100755
--- a/lorry-controller-remove-old-jobs
+++ b/lorry-controller-remove-old-jobs
@@ -26,14 +26,16 @@ import cliapp
class JobInfo(object):
- def __init__(self, job_id, exit_code, exit_timestamp):
+ def __init__(self, job_id, exit_code, exit_timestamp, start_timestamp):
self.job_id = job_id
self.exit_code = exit_code
self.exit_timestamp = exit_timestamp
+ self.start_timestamp = start_timestamp
def __repr__(self):
- return 'JobInfo(%s,%s,%s)' % (
- self.job_id, self.exit_code, self.exit_timestamp)
+ return 'JobInfo(%s,%s,%s,%s)' % (
+ self.job_id, self.exit_code, self.exit_timestamp,
+ self.start_timestamp)
class OldJobRemover(cliapp.Application):
@@ -108,7 +110,8 @@ class OldJobRemover(cliapp.Application):
exit_timestamp = self.parse_timestamp(obj['job_ended'])
else:
exit_timestamp = None
- return JobInfo(job_id, exit_code, exit_timestamp)
+ start_timestamp = self.parse_timestamp(obj['job_started'])
+ return JobInfo(job_id, exit_code, exit_timestamp, start_timestamp)
def parse_timestamp(self, timestamp):
return time.mktime(time.strptime(timestamp, '%Y-%m-%d %H:%M:%S UTC'))