2021-01-26 11:37:52 +01:00
|
|
|
from collections import Counter
|
2021-03-31 18:08:41 +02:00
|
|
|
from typing import Dict
|
2021-01-26 11:37:52 +01:00
|
|
|
|
|
|
|
|
2021-05-16 23:21:27 +02:00
|
|
|
def sort_by(_events: Counter) -> Dict[str, dict]:
|
2021-04-21 18:28:09 +02:00
|
|
|
majors = (
|
2021-01-26 11:37:52 +01:00
|
|
|
"guild",
|
|
|
|
"channel",
|
|
|
|
"message",
|
|
|
|
"invite",
|
|
|
|
"integration",
|
|
|
|
"presence",
|
|
|
|
"voice",
|
|
|
|
"other",
|
2021-04-21 18:28:09 +02:00
|
|
|
)
|
2021-03-31 18:08:41 +02:00
|
|
|
sorted_events: Dict[str, Dict] = {m: {} for m in majors}
|
2021-01-26 11:37:52 +01:00
|
|
|
|
|
|
|
for event, count in _events:
|
|
|
|
done = False
|
|
|
|
for m in majors:
|
|
|
|
if event.lower().startswith(m):
|
|
|
|
sorted_events[m][event] = count
|
|
|
|
done = True
|
|
|
|
if not done:
|
|
|
|
sorted_events["other"][event] = count
|
|
|
|
|
|
|
|
return sorted_events
|