Compare commits

...
6 Commits
Author SHA1 Message Date
imcompiling 4c40a4c0e5 Reordered to alphabetical like rest of classes.
build_develop / build (push) Successful in 1m25s
2024-09-20 21:19:23 -04:00
imcompiling c3f25b6b54 Add settings to DakinySettings.
build_develop / build (push) Has been cancelled
2024-09-20 21:18:14 -04:00
imcompiling e36b2425aa Add new tables for clan points.
build_develop / build (push) Successful in 1m24s
2024-09-20 21:15:09 -04:00
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
6 changed files with 44 additions and 14 deletions
+10
View File
@@ -19,10 +19,20 @@ class ChannelIds:
voting: int voting: int
@dataclass
class ClanPointSettings:
"""Class defines settings for Clan Points editable by Clan Council."""
points: int
verify: bool
weekly_limit: int
@dataclass @dataclass
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."""
+15
View File
@@ -59,4 +59,19 @@ CREATE TABLE EventPointsLimit (
Points int unsigned DEFAULT 0, Points int unsigned DEFAULT 0,
Week varchar(7) not null, Week varchar(7) not null,
PRIMARY KEY (UserId, Week) PRIMARY KEY (UserId, Week)
);
CREATE TABLE ClanPoints (
QuarterName varchar(30) not null,
UserId varchar(32) not null,
DiscordMember boolean not null,
Points int unsigned DEFAULT 0,
PRIMARY KEY (QuarterName, UserId)
);
CREATE TABLE ClanPointsLimit (
UserId varchar(32) not null,
Points int unsigned DEFAULT 0,
Week varchar(7) not null,
PRIMARY KEY (UserId, Week)
); );
+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.