printModerators: reduce Users to fullName

This commit is contained in:
Daniel Langbein 2021-03-02 15:43:37 +01:00
parent fa38fc4f6e
commit 794225b96b

View File

@ -34,6 +34,7 @@ def getModerators(dataDir: Path = fileUtil.getDataDir()) -> Dict[parseMeetings.U
if attendee.role == "MODERATOR"] if attendee.role == "MODERATOR"]
moderatorCount: Dict[parseMeetings.User, int] = {} moderatorCount: Dict[parseMeetings.User, int] = {}
moderator: parseMeetings.User
for moderator in moderators: for moderator in moderators:
count: int = 1 count: int = 1
if moderator in moderatorCount: if moderator in moderatorCount:
@ -46,5 +47,20 @@ def getModerators(dataDir: Path = fileUtil.getDataDir()) -> Dict[parseMeetings.U
def printModerators(): def printModerators():
moderators: Dict[parseMeetings.User, int] = getModerators() """
[print(moderator.fullName + ":\t" + str(count)) for moderator, count in moderators.items()] There may be multiple (different) User objects (with different UserIds) that have the
same name. This may come from one user joining different meetings.
This method reduces Users to their fullNames.
"""
moderatorUsers: Dict[parseMeetings.User, int] = getModerators()
moderatorNames: Dict[str, int] = {}
user: parseMeetings.User
for user, count in moderatorUsers.items():
if user.fullName in moderatorNames:
count += moderatorNames[user.fullName]
moderatorNames[user.fullName] = count
[print(fullName + ":\t" + str(count)) for fullName, count in moderatorNames.items()]