This commit is contained in:
+5
-10
@@ -8,12 +8,7 @@ from nextcord.ext import commands
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from database_setup.sql_data_classes import (
|
from database_setup.sql_data_classes import EventPoints, Presences, Votes, engine
|
||||||
ParticipationPoints,
|
|
||||||
Presences,
|
|
||||||
Votes,
|
|
||||||
engine,
|
|
||||||
)
|
|
||||||
from utils import VoteType
|
from utils import VoteType
|
||||||
|
|
||||||
|
|
||||||
@@ -48,14 +43,14 @@ class ViewCog(commands.Cog, name="View Commands"):
|
|||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
if quarter_name:
|
if quarter_name:
|
||||||
df = pd.read_sql_query(
|
df = pd.read_sql_query(
|
||||||
sql=session.query(ParticipationPoints)
|
sql=session.query(EventPoints)
|
||||||
.where(ParticipationPoints.Cycle.startswith(quarter_name))
|
.where(EventPoints.Cycle.startswith(quarter_name))
|
||||||
.statement,
|
.statement,
|
||||||
con=engine,
|
con=engine,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
df = pd.read_sql_query(
|
df = pd.read_sql_query(
|
||||||
sql=session.query(ParticipationPoints).statement,
|
sql=session.query(EventPoints).statement,
|
||||||
con=engine,
|
con=engine,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -231,7 +226,7 @@ class ViewCog(commands.Cog, name="View Commands"):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(ParticipationPoints.Cycle).distinct()
|
stmt = select(EventPoints.Cycle).distinct()
|
||||||
quarters = session.scalars(stmt)
|
quarters = session.scalars(stmt)
|
||||||
|
|
||||||
# if empty compare string
|
# if empty compare string
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ CREATE TABLE Presences (
|
|||||||
Presence varchar(100) not null
|
Presence varchar(100) not null
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE ParticipationPoints (
|
CREATE TABLE EventPoints (
|
||||||
Cycle varchar(30) not null,
|
Cycle varchar(30) not null,
|
||||||
UserId varchar(32) not null,
|
UserId varchar(32) not null,
|
||||||
DiscordMember boolean not null,
|
DiscordMember boolean not null,
|
||||||
@@ -52,4 +52,5 @@ CREATE TABLE ParticipationPoints (
|
|||||||
CREATE TABLE Messages (
|
CREATE TABLE Messages (
|
||||||
Path varchar(100) PRIMARY KEY,
|
Path varchar(100) PRIMARY KEY,
|
||||||
Id bigint unsigned not null
|
Id bigint unsigned not null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Base.prepare(autoload_with=engine)
|
|||||||
CouncilMembers = Base.classes.CouncilMembers
|
CouncilMembers = Base.classes.CouncilMembers
|
||||||
ElectionInformation = Base.classes.ElectionInformation
|
ElectionInformation = Base.classes.ElectionInformation
|
||||||
Messages = Base.classes.Messages
|
Messages = Base.classes.Messages
|
||||||
ParticipationPoints = Base.classes.ParticipationPoints
|
EventPoints = Base.classes.EventPoints
|
||||||
Presences = Base.classes.Presences
|
Presences = Base.classes.Presences
|
||||||
UserBirthday = Base.classes.UserBirthday
|
UserBirthday = Base.classes.UserBirthday
|
||||||
Votes = Base.classes.Votes
|
Votes = Base.classes.Votes
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ from sqlalchemy.orm import Session
|
|||||||
from config import DakinyConfig
|
from config import DakinyConfig
|
||||||
from database_setup.sql_data_classes import (
|
from database_setup.sql_data_classes import (
|
||||||
CouncilMembers,
|
CouncilMembers,
|
||||||
|
EventPoints,
|
||||||
Messages,
|
Messages,
|
||||||
ParticipationPoints,
|
|
||||||
Votes,
|
Votes,
|
||||||
engine,
|
engine,
|
||||||
)
|
)
|
||||||
@@ -333,14 +333,14 @@ def record_event_participation(config: DakinyConfig, users: list[str], is_member
|
|||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
for user in users:
|
for user in users:
|
||||||
stmt = (
|
stmt = (
|
||||||
select(ParticipationPoints)
|
select(EventPoints)
|
||||||
.where(ParticipationPoints.UserId == user)
|
.where(EventPoints.UserId == user)
|
||||||
.where(ParticipationPoints.Cycle == cycle)
|
.where(EventPoints.Cycle == cycle)
|
||||||
)
|
)
|
||||||
|
|
||||||
points = session.scalar(stmt)
|
points = session.scalar(stmt)
|
||||||
if points is None:
|
if points is None:
|
||||||
new_points = ParticipationPoints(
|
new_points = EventPoints(
|
||||||
Cycle=cycle,
|
Cycle=cycle,
|
||||||
UserId=user,
|
UserId=user,
|
||||||
DiscordMember=is_member,
|
DiscordMember=is_member,
|
||||||
@@ -366,14 +366,14 @@ def record_event_host(config: DakinyConfig, user: int):
|
|||||||
host_point_value = config.params.event_host_points
|
host_point_value = config.params.event_host_points
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = (
|
stmt = (
|
||||||
select(ParticipationPoints)
|
select(EventPoints)
|
||||||
.where(ParticipationPoints.UserId == str(user))
|
.where(EventPoints.UserId == str(user))
|
||||||
.where(ParticipationPoints.Cycle == cycle)
|
.where(EventPoints.Cycle == cycle)
|
||||||
)
|
)
|
||||||
|
|
||||||
points = session.scalar(stmt)
|
points = session.scalar(stmt)
|
||||||
if points is None:
|
if points is None:
|
||||||
new_points = ParticipationPoints(
|
new_points = EventPoints(
|
||||||
Cycle=cycle,
|
Cycle=cycle,
|
||||||
UserId=str(user),
|
UserId=str(user),
|
||||||
DiscordMember=True,
|
DiscordMember=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user