From 794225b96be228627f26cd69afd63028d51ff8ee Mon Sep 17 00:00:00 2001 From: langfingaz Date: Tue, 2 Mar 2021 15:43:37 +0100 Subject: [PATCH] printModerators: reduce Users to fullName --- src/langfingaz/recentModerators.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/langfingaz/recentModerators.py b/src/langfingaz/recentModerators.py index 5f9c2e9..65b2389 100644 --- a/src/langfingaz/recentModerators.py +++ b/src/langfingaz/recentModerators.py @@ -34,6 +34,7 @@ def getModerators(dataDir: Path = fileUtil.getDataDir()) -> Dict[parseMeetings.U if attendee.role == "MODERATOR"] moderatorCount: Dict[parseMeetings.User, int] = {} + moderator: parseMeetings.User for moderator in moderators: count: int = 1 if moderator in moderatorCount: @@ -46,5 +47,20 @@ def getModerators(dataDir: Path = fileUtil.getDataDir()) -> Dict[parseMeetings.U 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()]