Commit 140a4492 authored by David Huss's avatar David Huss 💬
Browse files

Fix Leaderport sorting and duration formatting

parent 3670715d
......@@ -166,20 +166,19 @@ def get_duration(meeting: XmlDictConfig) -> timedelta:
return duration
def strfdelta(duration: timedelta, fmt: str) -> str:
def strfdelta(duration: timedelta) -> str:
"""
Helper function for datetime.timedelta formatting, use like this:
strfdelta(delta_obj, "{days} days {hours}:{minutes}:{seconds}")
"""
d = {"days": duration.days}
d["hours"], remainder = divmod(duration.seconds, 3600)
d["minutes"], d["seconds"] = divmod(remainder, 60)
return fmt.format(**d)
s = int(duration.total_seconds())
return '{:02}:{:02}:{:02}'.format(s // 3600, s % 3600 // 60, s % 60)
def format_duration(meeting: XmlDictConfig) -> str:
duration = get_duration(meeting)
return strfdelta(duration, "{hours}:{minutes}")
return strfdelta(duration)
......@@ -200,7 +199,8 @@ def print_leaderboard(meetings: Iterable[XmlDictConfig], key: str):
participantCount)
"""
print("LEADERBOARD ({})".format(FRIENDLY_KEYNAMES[key]))
for m in meetings:
sorted_by = sorted([m for m in meetings], key=lambda x:int(x[key]), reverse=True)
for m in sorted_by:
print("{:>5} {:<45} {}".format(m[key], m["meetingName"], get_formated_presenter_name(m)))
......@@ -213,7 +213,7 @@ def print_duration_leaderboard(meetings: Iterable[XmlDictConfig]):
by_duration = sorted([m for m in meetings], key=lambda x:int(get_duration(x).total_seconds()), reverse=True)
for m in by_duration:
print("{:>5} {:<45} {}".format(format_duration(m), m["meetingName"], get_formated_presenter_name(m)))
print("{:>12} {:<45} {}".format(format_duration(m), m["meetingName"], get_formated_presenter_name(m)))
def print_overview(secret: Secret, bbb_url: Url):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment