Skip to content

Commit 3427705

Browse files
committed
Refactor list_jobs.py
1 parent 711a5d1 commit 3427705

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

ravenpackapi/examples/list_jobs.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,15 @@ def print_job(job):
2828
# start_date = "2022-11-22"
2929
# end_date = "2022-11-23"
3030
DAYS_BACK = 1
31-
end_date = datetime.datetime.utcnow().replace(microsecond=0)
32-
start_date = end_date - datetime.timedelta(days=DAYS_BACK)
31+
end = datetime.datetime.utcnow().replace(microsecond=0)
32+
start = end - datetime.timedelta(days=DAYS_BACK)
3333

3434
# Print all finished_jobs: completed or in error
35-
finished_jobs = api.list_jobs(start_date, end_date, status=["completed", "error"])
36-
print(
37-
f"{len(finished_jobs)} jobs completed or in error between {start_date} and {end_date}:"
38-
)
35+
finished_jobs = api.list_jobs(start, end, status=["completed", "error"])
36+
print(f"{len(finished_jobs)} jobs completed or in error between {start} and {end}:")
3937
print_jobs(finished_jobs)
4038

4139
# Print running jobs
42-
jobs = api.list_jobs(start_date, end_date, status=["processing"])
43-
print(
44-
f"{len(jobs)} jobs processing between {start_date} and {end_date} with tokens:"
45-
)
40+
jobs = api.list_jobs(start, end, status=["processing"])
41+
print(f"{len(jobs)} jobs processing between {start} and {end}:")
4642
print_jobs(jobs)

0 commit comments

Comments
 (0)