main: check for timeouts in all requests (also timeouted tasks)
This commit is contained in:
parent
f333fc7e56
commit
dd3d854259
3
main.py
3
main.py
@ -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(
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user