from typing import Optional
+def pretty_duration(seconds):
+ """Pretty print duration"""
+ hours, rem = divmod(seconds, 3600)
+ minutes, seconds = divmod(rem, 60)
+ if hours:
+ return f"{hours:0.0f}h{minutes:0.0f}m{seconds:0.0f}s"
+ if minutes:
+ return f"{minutes:0.0f}m{seconds:0.0f}s"
+ return f"{seconds:0.0f}s"
+
+
def get_gitlab_project(glab, name: str):
"""Finds a specified gitlab project for given user"""
if "/" in name:
from dateutil import parser
import gitlab
-from gitlab_common import read_token
+from gitlab_common import read_token, pretty_duration
REFRESH_WAIT = 30
MARGE_BOT_USER_ID = 9716
for mr in mrs:
updated = parser.parse(mr.updated_at)
now = datetime.now(timezone.utc)
- diff = str(now - updated).split('.', maxsplit=1)[0]
- print(f"{diff} | \u001b]8;;{mr.web_url}\u001b\\{mr.title}\u001b]8;;\u001b\\")
+ diff = (now - updated).total_seconds()
+ print(
+ f"⛭ \u001b]8;;{mr.web_url}\u001b\\{mr.title}\u001b]8;;\u001b\\ ({pretty_duration(diff)})"
+ )
print("Job waiting: " + str(jobs_num))