current election cycle shoud return quarter cycle if it can't find a cycle.
This commit is contained in:
@@ -49,7 +49,7 @@ def get_datetime(day: str) -> datetime:
|
||||
return datetime(year, month, day)
|
||||
|
||||
|
||||
def get_election_cycle_name(config: DakinyConfig) -> str:
|
||||
def get_election_name(config: DakinyConfig) -> str:
|
||||
"""
|
||||
Builds the unique name of the current election cycle
|
||||
|
||||
@@ -65,7 +65,7 @@ def get_election_cycle_name(config: DakinyConfig) -> str:
|
||||
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
|
||||
|
||||
|
||||
def get_cycle_name(config: DakinyConfig) -> str:
|
||||
def get_quarter_name(config: DakinyConfig) -> str:
|
||||
"""
|
||||
Builds the name of the current cycle/quarter
|
||||
|
||||
@@ -76,7 +76,7 @@ def get_cycle_name(config: DakinyConfig) -> str:
|
||||
str: the name of the cycle.
|
||||
"""
|
||||
|
||||
cycle = get_current_cycle(config)
|
||||
cycle = get_quarter_cycle(config)
|
||||
current_cycle = config.election_cycles[cycle]
|
||||
|
||||
return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
|
||||
@@ -93,7 +93,7 @@ def get_dm_election_name(config: DakinyConfig) -> str:
|
||||
str: the name of the election
|
||||
"""
|
||||
|
||||
return f"{get_election_cycle_name(config)}-dm"
|
||||
return f"{get_election_name(config)}-dm"
|
||||
|
||||
|
||||
def get_cl_election_name(config: DakinyConfig) -> str:
|
||||
@@ -107,7 +107,7 @@ def get_cl_election_name(config: DakinyConfig) -> str:
|
||||
str: the name of the election
|
||||
"""
|
||||
|
||||
return f"{get_election_cycle_name(config)}-cl"
|
||||
return f"{get_election_name(config)}-cl"
|
||||
|
||||
|
||||
def get_current_election_cycle(config: DakinyConfig) -> int:
|
||||
@@ -130,10 +130,11 @@ def get_current_election_cycle(config: DakinyConfig) -> int:
|
||||
):
|
||||
return cycle
|
||||
|
||||
return None
|
||||
# It isn't a current election, get the quarter
|
||||
return get_quarter_cycle(config)
|
||||
|
||||
|
||||
def get_current_cycle(config: DakinyConfig) -> int:
|
||||
def get_quarter_cycle(config: DakinyConfig) -> int:
|
||||
"""
|
||||
Returns the index for the current cycle/quarter. Defined as between term start and end. Shouldn't return none
|
||||
|
||||
@@ -171,7 +172,7 @@ def build_votes_str(config: DakinyConfig, guild: nextcord.Guild) -> str:
|
||||
|
||||
with Session(engine) as session:
|
||||
stmt = select(CouncilMembers).where(
|
||||
CouncilMembers.ElectionCycle == get_election_cycle_name(config)
|
||||
CouncilMembers.ElectionCycle == get_election_name(config)
|
||||
)
|
||||
|
||||
for nominee in sorted(
|
||||
@@ -180,9 +181,7 @@ def build_votes_str(config: DakinyConfig, guild: nextcord.Guild) -> str:
|
||||
):
|
||||
votes[nominee.MemberId] = 0
|
||||
|
||||
stmt = select(Votes).where(
|
||||
Votes.ElectionCycle == get_election_cycle_name(config)
|
||||
)
|
||||
stmt = select(Votes).where(Votes.ElectionCycle == get_election_name(config))
|
||||
|
||||
for vote in session.scalars(stmt):
|
||||
if vote.VotedForId is not None:
|
||||
@@ -212,7 +211,7 @@ def build_highcouncil_votes_str(config: DakinyConfig, guild: nextcord.Guild) ->
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
select(CouncilMembers)
|
||||
.where(CouncilMembers.ElectionCycle == get_election_cycle_name(config))
|
||||
.where(CouncilMembers.ElectionCycle == get_election_name(config))
|
||||
.filter(CouncilMembers.ClanLeaderSpeechId.is_not(None))
|
||||
)
|
||||
|
||||
@@ -230,7 +229,7 @@ def build_highcouncil_votes_str(config: DakinyConfig, guild: nextcord.Guild) ->
|
||||
|
||||
stmt = (
|
||||
select(CouncilMembers)
|
||||
.where(CouncilMembers.ElectionCycle == get_election_cycle_name(config))
|
||||
.where(CouncilMembers.ElectionCycle == get_election_name(config))
|
||||
.filter(CouncilMembers.DiscordManagerSpeechId.is_not(None))
|
||||
)
|
||||
|
||||
@@ -338,7 +337,7 @@ def record_event_participation(config: DakinyConfig, users: list[str], is_member
|
||||
is_member (bool): whether the users are a discord member or not
|
||||
"""
|
||||
|
||||
cycle = get_cycle_name(config)
|
||||
cycle = get_quarter_name(config)
|
||||
participation_point_value = config.params.event_participate_points
|
||||
with Session(engine) as session:
|
||||
for user in users:
|
||||
@@ -372,7 +371,7 @@ def record_event_host(config: DakinyConfig, user: int):
|
||||
config (DakinyConfig): Dakiny config for getting points
|
||||
user (int): Id of user that hosted.
|
||||
"""
|
||||
cycle = get_cycle_name(config)
|
||||
cycle = get_quarter_name(config)
|
||||
host_point_value = config.params.event_host_points
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
@@ -545,7 +544,7 @@ async def edit_clan_council_info(guild: nextcord.Guild, config: DakinyConfig):
|
||||
config.params.clan_info_channel_id
|
||||
)
|
||||
|
||||
election = get_election_cycle_name(config)
|
||||
election = get_election_name(config)
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
select(CouncilMembers.MemberId)
|
||||
@@ -571,7 +570,7 @@ async def edit_clan_council_info(guild: nextcord.Guild, config: DakinyConfig):
|
||||
if id not in (discord_manager, clan_leader)
|
||||
]
|
||||
|
||||
quarter = get_cycle_name(config)
|
||||
quarter = get_quarter_name(config)
|
||||
|
||||
with open(
|
||||
f"{TEMPLATES_DIR}/council_members.txt", mode="r", encoding="utf8"
|
||||
|
||||
Reference in New Issue
Block a user