LabCleaningBot: check for timeouts

This commit is contained in:
lemoer 2024-12-27 02:05:26 +01:00
parent 509e133913
commit c4725e2685
2 changed files with 10 additions and 0 deletions

View File

@ -334,6 +334,14 @@ class LabCleaningBot:
else:
print(res.unwrap_err())
# check for timeouts
for request in task.freshly_expired_requests(datetime.datetime.now()):
print("Request expired:", repr(request))
message = SendMessageSimple(
message="You did not respond to the task request in time.",
recipients=[request.user.name])
res = self.api.send_message(message)
session.commit()
await asyncio.sleep(1)

View File

@ -113,6 +113,8 @@ class Task(SQLModel, table=True):
if maybe_timeout is not None:
expired_requests.append(r)
return expired_requests
def create_additional_requests(self, now: datetime.datetime, session: Session) -> Result[List["ParticipationRequest"], List["ParticipationRequest"]]:
additional_requests = []