diff --git a/cogs/commands/view.py b/cogs/commands/view.py index b186812..c1d895a 100644 --- a/cogs/commands/view.py +++ b/cogs/commands/view.py @@ -8,12 +8,7 @@ from nextcord.ext import commands from sqlalchemy import select from sqlalchemy.orm import Session -from database_setup.sql_data_classes import ( - ParticipationPoints, - Presences, - Votes, - engine, -) +from database_setup.sql_data_classes import EventPoints, Presences, Votes, engine from utils import VoteType @@ -48,14 +43,14 @@ class ViewCog(commands.Cog, name="View Commands"): with Session(engine) as session: if quarter_name: df = pd.read_sql_query( - sql=session.query(ParticipationPoints) - .where(ParticipationPoints.Cycle.startswith(quarter_name)) + sql=session.query(EventPoints) + .where(EventPoints.Cycle.startswith(quarter_name)) .statement, con=engine, ) else: df = pd.read_sql_query( - sql=session.query(ParticipationPoints).statement, + sql=session.query(EventPoints).statement, con=engine, ) @@ -231,7 +226,7 @@ class ViewCog(commands.Cog, name="View Commands"): """ with Session(engine) as session: - stmt = select(ParticipationPoints.Cycle).distinct() + stmt = select(EventPoints.Cycle).distinct() quarters = session.scalars(stmt) # if empty compare string diff --git a/database_setup/database.sql b/database_setup/database.sql index 03ad9cb..5735865 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 ParticipationPoints ( +CREATE TABLE EventPoints ( Cycle varchar(30) not null, UserId varchar(32) not null, DiscordMember boolean not null, @@ -52,4 +52,5 @@ CREATE TABLE ParticipationPoints ( 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 007d432..48ebdec 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 -ParticipationPoints = Base.classes.ParticipationPoints +EventPoints = Base.classes.EventPoints Presences = Base.classes.Presences UserBirthday = Base.classes.UserBirthday Votes = Base.classes.Votes diff --git a/utils.py b/utils.py index 3caba58..375f934 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(ParticipationPoints) - .where(ParticipationPoints.UserId == user) - .where(ParticipationPoints.Cycle == cycle) + select(EventPoints) + .where(EventPoints.UserId == user) + .where(EventPoints.Cycle == cycle) ) points = session.scalar(stmt) if points is None: - new_points = ParticipationPoints( + new_points = EventPoints( 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(ParticipationPoints) - .where(ParticipationPoints.UserId == str(user)) - .where(ParticipationPoints.Cycle == cycle) + select(EventPoints) + .where(EventPoints.UserId == str(user)) + .where(EventPoints.Cycle == cycle) ) points = session.scalar(stmt) if points is None: - new_points = ParticipationPoints( + new_points = EventPoints( Cycle=cycle, UserId=str(user), DiscordMember=True,