diff --git a/cogs/commands/view.py b/cogs/commands/view.py index c1d895a..b186812 100644 --- a/cogs/commands/view.py +++ b/cogs/commands/view.py @@ -8,7 +8,12 @@ from nextcord.ext import commands from sqlalchemy import select from sqlalchemy.orm import Session -from database_setup.sql_data_classes import EventPoints, Presences, Votes, engine +from database_setup.sql_data_classes import ( + ParticipationPoints, + Presences, + Votes, + engine, +) from utils import VoteType @@ -43,14 +48,14 @@ class ViewCog(commands.Cog, name="View Commands"): with Session(engine) as session: if quarter_name: df = pd.read_sql_query( - sql=session.query(EventPoints) - .where(EventPoints.Cycle.startswith(quarter_name)) + sql=session.query(ParticipationPoints) + .where(ParticipationPoints.Cycle.startswith(quarter_name)) .statement, con=engine, ) else: df = pd.read_sql_query( - sql=session.query(EventPoints).statement, + sql=session.query(ParticipationPoints).statement, con=engine, ) @@ -226,7 +231,7 @@ class ViewCog(commands.Cog, name="View Commands"): """ with Session(engine) as session: - stmt = select(EventPoints.Cycle).distinct() + stmt = select(ParticipationPoints.Cycle).distinct() quarters = session.scalars(stmt) # if empty compare string diff --git a/database_setup/database.sql b/database_setup/database.sql index 5735865..03ad9cb 100644 --- a/database_setup/database.sql +++ b/database_setup/database.sql @@ -41,7 +41,7 @@ CREATE TABLE Presences ( Presence varchar(100) not null ); -CREATE TABLE EventPoints ( +CREATE TABLE ParticipationPoints ( Cycle varchar(30) not null, UserId varchar(32) not null, DiscordMember boolean not null, @@ -52,5 +52,4 @@ CREATE TABLE EventPoints ( CREATE TABLE Messages ( Path varchar(100) PRIMARY KEY, Id bigint unsigned not null -); - +); \ No newline at end of file diff --git a/database_setup/sql_data_classes.py b/database_setup/sql_data_classes.py index 48ebdec..007d432 100644 --- a/database_setup/sql_data_classes.py +++ b/database_setup/sql_data_classes.py @@ -15,7 +15,7 @@ Base.prepare(autoload_with=engine) CouncilMembers = Base.classes.CouncilMembers ElectionInformation = Base.classes.ElectionInformation Messages = Base.classes.Messages -EventPoints = Base.classes.EventPoints +ParticipationPoints = Base.classes.ParticipationPoints Presences = Base.classes.Presences UserBirthday = Base.classes.UserBirthday Votes = Base.classes.Votes diff --git a/utils.py b/utils.py index 375f934..3caba58 100644 --- a/utils.py +++ b/utils.py @@ -14,8 +14,8 @@ from sqlalchemy.orm import Session from config import DakinyConfig from database_setup.sql_data_classes import ( CouncilMembers, - EventPoints, Messages, + ParticipationPoints, Votes, engine, ) @@ -333,14 +333,14 @@ def record_event_participation(config: DakinyConfig, users: list[str], is_member with Session(engine) as session: for user in users: stmt = ( - select(EventPoints) - .where(EventPoints.UserId == user) - .where(EventPoints.Cycle == cycle) + select(ParticipationPoints) + .where(ParticipationPoints.UserId == user) + .where(ParticipationPoints.Cycle == cycle) ) points = session.scalar(stmt) if points is None: - new_points = EventPoints( + new_points = ParticipationPoints( Cycle=cycle, UserId=user, DiscordMember=is_member, @@ -366,14 +366,14 @@ def record_event_host(config: DakinyConfig, user: int): host_point_value = config.params.event_host_points with Session(engine) as session: stmt = ( - select(EventPoints) - .where(EventPoints.UserId == str(user)) - .where(EventPoints.Cycle == cycle) + select(ParticipationPoints) + .where(ParticipationPoints.UserId == str(user)) + .where(ParticipationPoints.Cycle == cycle) ) points = session.scalar(stmt) if points is None: - new_points = EventPoints( + new_points = ParticipationPoints( Cycle=cycle, UserId=str(user), DiscordMember=True,