Skip to content

Commit 3c5c381

Browse files
authored
gumana auto terminate fuck u (#46)
2 parents d7a1f1e + 1374937 commit 3c5c381

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

backend/app/app.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,25 @@ def get_all_waitlist_entries():
377377
print(f"Error fetching waitlist entries: {err}")
378378
return None
379379

380+
def remove_reservation_by_id(reservation_id):
381+
connection = get_db_connection(db_config)
382+
if connection:
383+
try:
384+
cursor = connection.cursor()
385+
query = """
386+
DELETE FROM Reservations
387+
WHERE ReservationID = %s
388+
"""
389+
cursor.execute(query, (reservation_id,))
390+
connection.commit()
391+
cursor.close()
392+
connection.close()
393+
return {'message': 'Reservation removed successfully'}
394+
except mysql.connector.Error as err:
395+
print(f"Error removing reservation: {err}")
396+
connection.rollback()
397+
return {'error': f"Error removing reservation: {err}"}
398+
380399
def move_to_completed_reservations(reservation_id):
381400
connection = get_db_connection(db_config)
382401
if connection:
@@ -402,10 +421,7 @@ def move_to_completed_reservations(reservation_id):
402421
)
403422
cursor.execute(insert_query, values)
404423

405-
delete_query = """
406-
DELETE FROM Reservations WHERE ReservationID = %s
407-
"""
408-
cursor.execute(delete_query, (reservation_id,))
424+
remove_reservation_by_id(reservation_id)
409425

410426
connection.commit()
411427
cursor.close()
@@ -435,6 +451,7 @@ def check_reservation_end_route():
435451
print(f"Fetched Reservations: {reservations}") # Debugging line
436452

437453
for reservation in reservations:
454+
print(f"EndTime of Reservation {reservation['ReservationID']}: {reservation['EndTime']}")
438455
move_to_completed_reservations(reservation['ReservationID'])
439456

440457
cursor.close()
@@ -445,6 +462,7 @@ def check_reservation_end_route():
445462
print(f"Error checking reservations end: {e}")
446463
return jsonify(error='Error checking reservations end'), 500
447464

465+
448466
@app.route('/api/remove-reservation/<string:chair_id>', methods=['DELETE'])
449467
def remove_reservation_route(chair_id):
450468
try:

backend/db/init.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CREATE TABLE Reservations (
2727
EndTime VARCHAR(225) NOT NULL,
2828
Seat VARCHAR(50),
2929
TableFee DECIMAL(10,2) DEFAULT 0.00,
30-
FOREIGN KEY (UserID) REFERENCES Users(UserID) ON DELETE CASCADE
30+
FOREIGN KEY (UserID) REFERENCES Users(UserID)
3131

3232
);
3333

0 commit comments

Comments
 (0)