Skip to content

Commit

Permalink
userDash | add check of task age is not None
Browse files Browse the repository at this point in the history
  • Loading branch information
tkorchug committed Nov 21, 2024
1 parent 4b10315 commit 489c04b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/libs/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def prepare_user_dash_plots(tasks, **kwargs):
plots_dict['ntasks_by_status']['data'][task['status']] = 0
plots_dict['ntasks_by_status']['data'][task['status']] += 1

if task['age'] > 0:
if 'age' in task and task['age'] is not None and task['age'] > 0:
if task['status'] not in plots_dict['age_hist']['data']['data_raw']:
plots_dict['age_hist']['data']['data_raw'][task['status']] = []
plots_dict['age_hist']['data']['data_raw'][task['status']].append((task['age']))
Expand Down Expand Up @@ -218,7 +218,9 @@ def humanize_metrics(metrics):

for key, thresholds in metrics_thresholds.items():
if key in md:
metric_defs[md]['class'].extend([c for c, crange in thresholds.items() if metric_defs[md]['value'] >= crange[0] and metric_defs[md]['value'] < crange[1]])
metric_defs[md]['class'].extend(
[c for c, crange in thresholds.items() if crange[0] <= metric_defs[md]['value'] < crange[1]]
)

metric_defs[md]['class'] = metric_defs[md]['class'][0] if len(metric_defs[md]['class']) > 0 else 'ok'
metrics_list.append(metric_defs[md])
Expand Down

0 comments on commit 489c04b

Please sign in to comment.