Add marathon finish button and system
This commit is contained in:
@@ -104,6 +104,10 @@ async def spin_wheel(marathon_id: int, current_user: CurrentUser, db: DbSession)
|
||||
if marathon.status != MarathonStatus.ACTIVE.value:
|
||||
raise HTTPException(status_code=400, detail="Marathon is not active")
|
||||
|
||||
# Check if marathon has expired by end_date
|
||||
if marathon.end_date and datetime.utcnow() > marathon.end_date:
|
||||
raise HTTPException(status_code=400, detail="Marathon has ended")
|
||||
|
||||
participant = await get_participant_or_403(db, current_user.id, marathon_id)
|
||||
|
||||
# Check no active regular assignment (event assignments are separate)
|
||||
@@ -232,6 +236,10 @@ async def get_current_assignment(marathon_id: int, current_user: CurrentUser, db
|
||||
challenge = assignment.challenge
|
||||
game = challenge.game
|
||||
|
||||
# Calculate drop penalty (considers active event for double_risk)
|
||||
active_event = await event_service.get_active_event(db, marathon_id)
|
||||
drop_penalty = points_service.calculate_drop_penalty(participant.drop_count, active_event)
|
||||
|
||||
return AssignmentResponse(
|
||||
id=assignment.id,
|
||||
challenge=ChallengeResponse(
|
||||
@@ -255,6 +263,7 @@ async def get_current_assignment(marathon_id: int, current_user: CurrentUser, db
|
||||
streak_at_completion=assignment.streak_at_completion,
|
||||
started_at=assignment.started_at,
|
||||
completed_at=assignment.completed_at,
|
||||
drop_penalty=drop_penalty,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class AssignmentResponse(BaseModel):
|
||||
streak_at_completion: int | None = None
|
||||
started_at: datetime
|
||||
completed_at: datetime | None = None
|
||||
drop_penalty: int = 0 # Calculated penalty if dropped
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
Reference in New Issue
Block a user