Skip to content

Commit aace902

Browse files
committed
Deal with unexpected problems in data when calculating statistics
1 parent 46fd00b commit aace902

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

api/simqueue/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ async def update_log(job_id, log, append=False):
291291

292292

293293
def get_list_filter(attr, value):
294-
if len(value) > 0:
294+
assert isinstance(value, str)
295+
if len(value) > 1:
295296
return attr.in_(value)
296297
else:
297298
return attr == value[0]

api/simqueue/resources/statistics.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async def job_count(start: date = None, end: date = None, interval: int = 7):
5858
[
5959
(timestamp["timestamp_completion"].date() - start).days
6060
for timestamp in completion_timestamps
61+
if timestamp["timestamp_completion"]
6162
],
6263
dtype=int,
6364
)
@@ -265,7 +266,11 @@ async def resource_usage(start: date = None, end: date = None, interval: int = 7
265266
fields=["timestamp_completion", "resource_usage"],
266267
)
267268
completed = np.array(
268-
[(job["timestamp_completion"].date() - start).days for job in completed_jobs],
269+
[
270+
(job["timestamp_completion"].date() - start).days
271+
for job in completed_jobs
272+
if job["timestamp_completion"]
273+
],
269274
dtype=int,
270275
)
271276
usage_per_job = np.array([job["resource_usage"] for job in completed_jobs])

0 commit comments

Comments
 (0)