main: check for timeouts in all requests (also timeouted tasks)

This commit is contained in:
lemoer 2024-12-27 20:20:25 +01:00
parent f333fc7e56
commit dd3d854259
2 changed files with 5 additions and 1 deletions

View File

@ -426,7 +426,8 @@ You have time to answer for {format_seconds(task.timeout)}."""
else:
print(res.unwrap_err())
# check for timeouts
# Check for timeouts (for all tasks, also those that are timeouted)
for task in get_tasks(session):
for request in task.freshly_expired_requests(now()):
print("Request expired:", repr(request))
message = SendMessageSimple(

View File

@ -137,6 +137,9 @@ class Task(SQLModel, table=True):
def get_active_tasks(session: Session, now: datetime.datetime) -> List[Task]:
return session.exec(select(Task).where(Task.due > now)).all()
def get_tasks(session: Session) -> List[Task]:
return session.exec(select(Task)).all()
class ParticipationState(enum.Enum):
REQUESTED = "requested"
ACCEPTED = "accepted"