Compare commits

...
Author SHA1 Message Date
imcompiling d7a0480c2b Merge branch '78-config-for-skipping-election-cycle'
build_latest / build (push) Successful in 17s
build_release / build (push) Successful in 17s
build_develop / build (push) Has been cancelled
2024-09-07 15:49:21 -04:00
imcompiling 8457c09b5b Remove bad import.
build_develop / build (push) Successful in 1m24s
2024-09-07 15:46:52 -04:00
imcompiling 3c31d0ad33 Add active parameter to elections. Only return an election for use if the election is active. 2024-09-07 15:46:30 -04:00
imcompiling 70676a98dd Merge branch '77-verification-for-splits'
build_latest / build (push) Successful in 16s
build_release / build (push) Successful in 16s
2024-09-07 15:15:26 -04:00
5 changed files with 20 additions and 14 deletions
+1
View File
@@ -23,6 +23,7 @@ class ChannelIds:
class Election: class Election:
"""Class defines relevant election dates.""" """Class defines relevant election dates."""
active: bool
election_start: str election_start: str
highcouncil_election_announce: str highcouncil_election_announce: str
highcouncil_election_end: str highcouncil_election_end: str
+1
View File
@@ -49,6 +49,7 @@ class Election:
""" """
self.cycle = cycle self.cycle = cycle
self.election_cycle = settings.election_cycles[self.cycle] self.election_cycle = settings.election_cycles[self.cycle]
self.active = self.election_cycle.active
self.election_start: datetime = get_datetime(self.election_cycle.election_start) self.election_start: datetime = get_datetime(self.election_cycle.election_start)
self.term_start: datetime = get_datetime(self.election_cycle.term_start) self.term_start: datetime = get_datetime(self.election_cycle.term_start)
self.term_end: datetime = get_datetime(self.election_cycle.term_end) self.term_end: datetime = get_datetime(self.election_cycle.term_end)
+8 -8
View File
@@ -5,7 +5,7 @@ from nextcord.ext import application_checks, commands
from classes.election import Election from classes.election import Election
from DakinySettings import settings from DakinySettings import settings
from utils import GUILDS, get_current_election_cycle from utils import GUILDS, get_active_election_cycle
ME = 206602713511886849 ME = 206602713511886849
@@ -40,7 +40,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.election_start_action() await cycle.election_start_action()
@@ -56,7 +56,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.voting_start_action() await cycle.voting_start_action()
@@ -72,7 +72,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.voting_end_action() await cycle.voting_end_action()
@@ -88,7 +88,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.highcouncil_election_start_action() await cycle.highcouncil_election_start_action()
@@ -104,7 +104,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.election_reminder() await cycle.election_reminder()
@@ -120,7 +120,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.check_date() await cycle.check_date()
@@ -136,7 +136,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.term_start_action() await cycle.term_start_action()
+5 -3
View File
@@ -13,7 +13,7 @@ from classes.election import Election
from DakinySettings import settings from DakinySettings import settings
from database_setup.sql_data_classes import UserBirthday, engine from database_setup.sql_data_classes import UserBirthday, engine
from main import birthday_list from main import birthday_list
from utils import get_current_election_cycle from utils import get_active_election_cycle
if TYPE_CHECKING: if TYPE_CHECKING:
import nextcord import nextcord
@@ -75,13 +75,15 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
Returns: Returns:
Election: Current election cycle, None if there is no election happening. Election: Current election cycle, None if there is no election happening.
""" """
cycle = get_current_election_cycle() cycle = get_active_election_cycle()
# prevent exception from using cycle as an Int in an array # prevent exception from using cycle as an Int in an array
if cycle is None: if cycle is None:
return None return None
return Election(cycle, self.bot.get_guild(settings.params.guild_id)) election = Election(cycle, self.bot.get_guild(settings.params.guild_id))
return election if election.active else None
def update_birthdays(self) -> None: def update_birthdays(self) -> None:
"""Goes through database to collect all birthdays that are today. Adds user's id to birthday list.""" """Goes through database to collect all birthdays that are today. Adds user's id to birthday list."""
+5 -3
View File
@@ -64,7 +64,7 @@ def get_election_name() -> str:
Returns: Returns:
str: the name of the election cycle str: the name of the election cycle
""" """
cycle = get_current_election_cycle() cycle = get_active_election_cycle()
current_cycle = settings.election_cycles[cycle] current_cycle = settings.election_cycles[cycle]
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}" return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
@@ -82,7 +82,7 @@ def get_quarter_name() -> str:
return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}" return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
def get_current_election_cycle() -> int: def get_active_election_cycle() -> int:
""" """
Returns index for active election. An election is considered active between the election start and the term start. Returns index for active election. An election is considered active between the election start and the term start.
@@ -104,7 +104,9 @@ def get_current_election_cycle() -> int:
def get_quarter_cycle() -> int: def get_quarter_cycle() -> int:
""" """
Returns the index for the current cycle/quarter. Defined as between term start and end. Shouldn't return none. Returns the index for the current cycle/quarter. Defined as between term start and end.
Can return None if entire year isn't covered by cycles.
Returns: Returns:
int: cycle index for current cycle. int: cycle index for current cycle.