From b8e35b5e90ad322b0e7877fcffa4773b5de530e7 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Sun, 17 Dec 2023 14:17:35 -0500 Subject: [PATCH] Fix bugs with the voting results string builder. --- utils.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/utils.py b/utils.py index 58804b4..7fb2c93 100644 --- a/utils.py +++ b/utils.py @@ -153,8 +153,10 @@ def build_highcouncil_votes_str(config: DakinyConfig) -> str: dm_votes: dict[int, int] = {} with Session(engine) as session: - stmt = select(CouncilMembers).where( - CouncilMembers.ElectionCycle == get_election_cycle_name(config) + stmt = ( + select(CouncilMembers) + .where(CouncilMembers.ElectionCycle == get_election_cycle_name(config)) + .filter(CouncilMembers.ClanLeaderSpeechId.is_not(None)) ) for nominee in session.scalars(stmt): @@ -166,8 +168,10 @@ def build_highcouncil_votes_str(config: DakinyConfig) -> str: if vote.VotedForId is not None: cl_votes[vote.VotedForId] += 1 - stmt = select(CouncilMembers).where( - CouncilMembers.ElectionCycle == get_election_cycle_name(config) + stmt = ( + select(CouncilMembers) + .where(CouncilMembers.ElectionCycle == get_election_cycle_name(config)) + .filter(CouncilMembers.DiscordManagerSpeechId.is_not(None)) ) for nominee in session.scalars(stmt): @@ -199,9 +203,11 @@ def user_vote_str(votes: dict[int, int]) -> str: Returns: str: The string showing names and number of votes. """ + ret_str: str = "" for user_id, num_votes in votes.items(): - return f"\n<@{user_id}>: {'☑️' * num_votes}" + ret_str += f"\n<@{user_id}>: {'☑️' * num_votes}" + return ret_str def decorate_nomination(user_id: int, speech: str) -> str: