From b292f956e8808448c0b2c99a279f4b0518509ab5 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Sat, 16 Dec 2023 21:52:56 -0500 Subject: [PATCH] Add functions for different election names within same cycle. --- utils.py | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 2b64515..1e3cc84 100644 --- a/utils.py +++ b/utils.py @@ -38,13 +38,46 @@ def get_election_cycle_name(config: DakinyConfig) -> str: """ Builds the unique name of the current election cycle + Args: + config (DakinyConfig): the config used to know the election cycle. + Returns: str: the name of the election cycle """ cycle = get_current_cycle(config) current_cycle = config.election_cycles[cycle] - return f"vote-{get_datetime(current_cycle.election_start).year}-{current_cycle.name}" + return ( + f"vote-{get_datetime(current_cycle.election_start).year}-{current_cycle.name}" + ) + + +def get_dm_election_name(config: DakinyConfig) -> str: + """ + creates the name of the discord manager election + + Args: + config (DakinyConfig): Config sent to get_election_cycle_name + + Returns: + str: the name of the election + """ + + return f"{get_election_cycle_name(config)}-dm" + + +def get_cl_election_name(config: DakinyConfig) -> str: + """ + creates the name of the clan leader election + + Args: + config (DakinyConfig): Config sent to get_election_cycle_name + + Returns: + str: the name of the election + """ + + return f"{get_election_cycle_name(config)}-cl" def get_current_cycle(config: DakinyConfig) -> int: @@ -84,7 +117,9 @@ def build_votes_str(config: DakinyConfig) -> str: 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) + ) for nominee in session.scalars(stmt): votes[nominee.MemberId] = 0