Rename ParticipationPoints to EventPoints.
This commit is contained in:
@@ -15,9 +15,9 @@ from sqlalchemy.orm import Session
|
||||
from config import DakinyConfig
|
||||
from database_setup.sql_data_classes import (
|
||||
CouncilMembers,
|
||||
EventPoints,
|
||||
EventPointsLimit,
|
||||
Messages,
|
||||
ParticipationPoints,
|
||||
Votes,
|
||||
engine,
|
||||
)
|
||||
@@ -318,16 +318,12 @@ def record_event_points(config: DakinyConfig, users: Sequence[str], add_points:
|
||||
quarter_name = get_quarter_name(config)
|
||||
with Session(engine) as session:
|
||||
for user in users:
|
||||
stmt = (
|
||||
select(ParticipationPoints)
|
||||
.where(ParticipationPoints.UserId == user)
|
||||
.where(ParticipationPoints.Cycle == quarter_name)
|
||||
)
|
||||
stmt = select(EventPoints).where(EventPoints.UserId == user).where(EventPoints.Cycle == quarter_name)
|
||||
|
||||
points = session.scalar(stmt)
|
||||
if points is None:
|
||||
add_points = get_allowed_points(session, config.params.event_points_weekly_limit, user, add_points)
|
||||
new_points = ParticipationPoints(
|
||||
new_points = EventPoints(
|
||||
Cycle=quarter_name,
|
||||
UserId=user,
|
||||
DiscordMember=is_member,
|
||||
@@ -371,11 +367,7 @@ def get_allowed_points(session: Session, points_limit: int, user: str, points: i
|
||||
add_points = points
|
||||
session.add(new_limit)
|
||||
else:
|
||||
add_points = (
|
||||
points
|
||||
if limit.Points + points <= points_limit
|
||||
else (max(0, points_limit - limit.Points))
|
||||
)
|
||||
add_points = points if limit.Points + points <= points_limit else (max(0, points_limit - limit.Points))
|
||||
limit.Points += add_points
|
||||
|
||||
session.commit()
|
||||
|
||||
Reference in New Issue
Block a user