Change ElectionCycle class to Election. Change ElectionCycle column in database to ElectionName. Update some variables for clarification.

This commit is contained in:
2024-09-03 11:24:28 -04:00
parent 306e0d687a
commit eb5102578d
10 changed files with 71 additions and 79 deletions
+6 -6
View File
@@ -9,7 +9,7 @@ from pytz import timezone
from sqlalchemy import select
from sqlalchemy.orm import Session
from classes.election_cycle import ElectionCycle
from classes.election import Election
from database_setup.sql_data_classes import UserBirthday, engine
from main import birthday_list
from utils import get_current_election_cycle
@@ -43,7 +43,7 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
election is over to delete the current election object.
"""
if self.current_election is None:
self.current_election = self.get_election_cycle()
self.current_election = self.get_election()
if self.current_election is not None:
await self.current_election.check_date()
@@ -65,16 +65,16 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
await self.bot.wait_until_ready()
# Bot needs to know guilds to get the current cycle.
self.current_election = self.get_election_cycle()
self.current_election = self.get_election()
def get_election_cycle(self) -> ElectionCycle:
def get_election(self) -> Election:
"""
Creates an object for the current election cycle if one is active.
An election is considered active between the election start and the term start.
Returns:
ElectionCycle: Current election cycle, None if there is no election happening.
Election: Current election cycle, None if there is no election happening.
"""
config: DakinyConfig = self.bot.config
cycle = get_current_election_cycle(config)
@@ -83,7 +83,7 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
if cycle is None:
return None
return ElectionCycle(cycle, config, self.bot.get_guild(config.params.guild_id))
return Election(cycle, config, self.bot.get_guild(config.params.guild_id))
def update_birthdays(self) -> None:
"""Goes through database to collect all birthdays that are today. Adds user's id to birthday list."""