Add functions for different election names within same cycle.
This commit is contained in:
@@ -38,13 +38,46 @@ def get_election_cycle_name(config: DakinyConfig) -> str:
|
|||||||
"""
|
"""
|
||||||
Builds the unique name of the current election cycle
|
Builds the unique name of the current election cycle
|
||||||
|
|
||||||
|
Args:
|
||||||
|
config (DakinyConfig): the config used to know the election cycle.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: the name of the election cycle
|
str: the name of the election cycle
|
||||||
"""
|
"""
|
||||||
cycle = get_current_cycle(config)
|
cycle = get_current_cycle(config)
|
||||||
current_cycle = config.election_cycles[cycle]
|
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:
|
def get_current_cycle(config: DakinyConfig) -> int:
|
||||||
@@ -84,7 +117,9 @@ def build_votes_str(config: DakinyConfig) -> str:
|
|||||||
votes: dict[int, int] = {}
|
votes: dict[int, int] = {}
|
||||||
|
|
||||||
with Session(engine) as session:
|
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):
|
for nominee in session.scalars(stmt):
|
||||||
votes[nominee.MemberId] = 0
|
votes[nominee.MemberId] = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user