summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/main.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/backend/main.py b/backend/main.py
index 889e389..6c49dbf 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -107,11 +107,6 @@ def reminder_timer_finished(timer_id):
print("timer almost finished", timer_id)
end_date = datetime.datetime.now() + datetime.timedelta(seconds=5)
scheduler.add_job(final_timer_finished, 'date', run_date=end_date, id=timer_id, args=[timer_id])
- cursor.execute(f"SELECT * FROM timers WHERE timer_id = '{timer_id}'")
- out = cursor.fetchall()
-
- for row in out:
- machine_status[row[4] - 1][row[5] - 1] = Status.FINISHED.name
def final_timer_finished(timer_id):
@@ -120,12 +115,7 @@ def final_timer_finished(timer_id):
out = cursor.fetchall()
for row in out:
- machine_status[row[4] - 1][row[5] - 1] = Status.EMPTY.name
- machine_times[row[4] - 1][row[5] - 1] = None
- machine_durations[row[4] - 1][row[5] - 1] = None
-
- cursor.execute(f"DELETE FROM timers WHERE timer_id = {timer_id}")
- conn.commit()
+ machine_status[row[4] - 1][row[5] - 1] = Status.FINISHED.name
def create_session(response: fastapi.Response):
@@ -260,6 +250,13 @@ def finish_laundry(data: FinishRequestData, response: fastapi.Response, session_
cursor.execute(f"SELECT * FROM timers WHERE id = '{data.id}'")
row = cursor.fetchall()[0]
+ machine_status[row[4] - 1][row[5] - 1] = Status.EMPTY.name
+ machine_times[row[4] - 1][row[5] - 1] = None
+ machine_durations[row[4] - 1][row[5] - 1] = None
+
+ cursor.execute(f"DELETE FROM timers WHERE timer_id = {row[0]}")
+ conn.commit()
+
if session_key != row[1]:
response.status_code = fastapi.status.HTTP_401_UNAUTHORIZED
return "session key mismatch with timer id, dubious and hence unauthorised."