Skip to content

Commit 5bb9e96

Browse files
committed
Sort by school percent.
1 parent c946058 commit 5bb9e96

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • usr/lib/python3/dist-packages/linuxmusterCli/typers

‎usr/lib/python3/dist-packages/linuxmusterCli/typers/quotas.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def add_quotas(user):
6060

6161
global_level = "[green]"
6262
school_level = "[green]"
63+
school_percent = 0
6364

6465
if quotas['linuxmuster-global']['hard_limit'] != "NO LIMIT":
6566
global_percent = 100 * quotas['linuxmuster-global']['used'] / quotas['linuxmuster-global']['hard_limit']
@@ -75,17 +76,24 @@ def add_quotas(user):
7576
elif school_percent > 75:
7677
school_level = "[yellow]"
7778

78-
table_quotas.add_row(
79+
return (
7980
user,
8081
f"{global_level}{quotas['linuxmuster-global']['used']:>9.2f} / {quotas['linuxmuster-global']['hard_limit']}",
8182
f"{school_level}{quotas[school]['used']:>9.2f} / {quotas[school]['hard_limit']}",
8283
quotas['cloud'],
83-
quotas['mail']
84+
quotas['mail'],
85+
school_percent
8486
)
8587

8688
with futures.ThreadPoolExecutor() as executor:
8789
infos = executor.map(add_quotas, users)
8890

91+
# Sort by school_percent
92+
results = sorted(list(infos), key=lambda l: -l[-1])
93+
94+
for result in results:
95+
table_quotas.add_row(*result[:-1])
96+
8997
if state.format:
9098
printf.format(data)
9199
else:

0 commit comments

Comments
 (0)