Compare commits

...
5 Commits
Author SHA1 Message Date
imcompiling 8fb59ba394 Remove unused noqa.
build_develop / build (push) Failing after 42s
2024-09-03 11:00:48 -04:00
imcompiling 7b521893d3 Rename ParticipationPoints to EventPoints. 2024-09-03 10:59:39 -04:00
imcompiling 19e654aed0 Update ruff version 2024-09-03 10:59:28 -04:00
imcompiling 0d38bc82c4 Merge commit 'b64e2471fa7fdca5bb925c54eaa9adee78a19e5d'
build_latest / build (push) Successful in 16s
build_release / build (push) Successful in 16s
build_develop / build (push) Successful in 2m10s
2024-08-02 16:23:45 -04:00
imcompiling b64e2471fa Prevent double period.
build_develop / build (push) Successful in 1m28s
2024-08-02 16:23:35 -04:00
6 changed files with 15 additions and 23 deletions
+4 -2
View File
@@ -65,7 +65,7 @@ class RecordCog(commands.Cog, name="Record Commands"):
) )
@record.subcommand(description="Record a miscellaneous point for a clan member.") @record.subcommand(description="Record a miscellaneous point for a clan member.")
async def point( # noqa: PLR0913 async def point(
self, self,
interaction: nextcord.Interaction, interaction: nextcord.Interaction,
activity: str = nextcord.SlashOption( activity: str = nextcord.SlashOption(
@@ -140,7 +140,9 @@ class RecordCog(commands.Cog, name="Record Commands"):
self.bot.config.params.event_post_channel_id self.bot.config.params.event_post_channel_id
) )
msg = f"<@{interaction.user.id}> has given {recipient_str} points for the {activity} activity. Justification: {justification}." # noqa: E501 msg = f"<@{interaction.user.id}> has given {recipient_str} points for the {activity} activity. Justification: {justification}" # noqa: E501
if not msg.endswith("."):
msg += "."
await event_channel.send(msg) await event_channel.send(msg)
await interaction.response.send_message("Point has been added.", ephemeral=True) await interaction.response.send_message("Point has been added.", ephemeral=True)
+4 -6
View File
@@ -7,7 +7,7 @@ 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 (
ParticipationPoints, EventPoints,
Presences, Presences,
Votes, Votes,
engine, engine,
@@ -49,14 +49,12 @@ class ViewCog(commands.Cog, name="View Commands"):
with Session(engine) as session: with Session(engine) as session:
if quarter_name: if quarter_name:
ppdf = pd.read_sql_query( ppdf = pd.read_sql_query(
sql=session.query(ParticipationPoints) sql=session.query(EventPoints).where(EventPoints.Cycle.startswith(quarter_name)).statement,
.where(ParticipationPoints.Cycle.startswith(quarter_name))
.statement,
con=engine, con=engine,
) )
else: else:
ppdf = pd.read_sql_query( ppdf = pd.read_sql_query(
sql=session.query(ParticipationPoints).statement, sql=session.query(EventPoints).statement,
con=engine, con=engine,
) )
@@ -203,7 +201,7 @@ class ViewCog(commands.Cog, name="View Commands"):
quarter_name (str): String to run autocomplete on. quarter_name (str): String to run autocomplete on.
""" """
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
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -14,7 +14,7 @@ CouncilMembers = Base.classes.CouncilMembers
ElectionInformation = Base.classes.ElectionInformation ElectionInformation = Base.classes.ElectionInformation
EventPointsLimit = Base.classes.EventPointsLimit EventPointsLimit = Base.classes.EventPointsLimit
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
+1 -1
View File
@@ -21,7 +21,7 @@ setuptools = "^70.0.0"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
ruff = "^0.4.5" ruff = "^0.6.3"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]
+4 -12
View File
@@ -15,9 +15,9 @@ 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,
EventPointsLimit, EventPointsLimit,
Messages, Messages,
ParticipationPoints,
Votes, Votes,
engine, engine,
) )
@@ -318,16 +318,12 @@ def record_event_points(config: DakinyConfig, users: Sequence[str], add_points:
quarter_name = get_quarter_name(config) quarter_name = get_quarter_name(config)
with Session(engine) as session: with Session(engine) as session:
for user in users: for user in users:
stmt = ( stmt = select(EventPoints).where(EventPoints.UserId == user).where(EventPoints.Cycle == quarter_name)
select(ParticipationPoints)
.where(ParticipationPoints.UserId == user)
.where(ParticipationPoints.Cycle == quarter_name)
)
points = session.scalar(stmt) points = session.scalar(stmt)
if points is None: if points is None:
add_points = get_allowed_points(session, config.params.event_points_weekly_limit, user, add_points) add_points = get_allowed_points(session, config.params.event_points_weekly_limit, user, add_points)
new_points = ParticipationPoints( new_points = EventPoints(
Cycle=quarter_name, Cycle=quarter_name,
UserId=user, UserId=user,
DiscordMember=is_member, DiscordMember=is_member,
@@ -371,11 +367,7 @@ def get_allowed_points(session: Session, points_limit: int, user: str, points: i
add_points = points add_points = points
session.add(new_limit) session.add(new_limit)
else: else:
add_points = ( add_points = points if limit.Points + points <= points_limit else (max(0, points_limit - limit.Points))
points
if limit.Points + points <= points_limit
else (max(0, points_limit - limit.Points))
)
limit.Points += add_points limit.Points += add_points
session.commit() session.commit()