Skip to content

Commit e57e6e0

Browse files
committed
feat: humanize run interval in dashboard view
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 10ee2bf commit e57e6e0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎vulnerabilities/templatetags/utils.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,17 @@ def normalize_links(value):
6464

6565
markdown_links = re.compile(r"\[([^\]]+)\]\((https?://[^\s)]+)\s*\)")
6666
return markdown_links.sub(r"\1 \2", value)
67+
68+
69+
@register.filter
70+
def humanize_duration(minutes):
71+
"""Humanize pipeline run interval."""
72+
if minutes < 60:
73+
unit = "minute" if minutes == 1 else "minutes"
74+
return f"{minutes} {unit}"
75+
76+
hours = minutes / 60
77+
value = int(hours) if hours.is_integer() else round(hours, 1)
78+
79+
unit = "hour" if value == 1 else "hours"
80+
return f"{value} {unit}"

0 commit comments

Comments
 (0)