Skip to content

Commit

Permalink
gumana auto terminate fuck u
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Sicat committed Dec 20, 2023
1 parent 5d663b6 commit 1374937
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions backend/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,25 @@ def get_all_waitlist_entries():
print(f"Error fetching waitlist entries: {err}")
return None

def remove_reservation_by_id(reservation_id):
connection = get_db_connection(db_config)
if connection:
try:
cursor = connection.cursor()
query = """
DELETE FROM Reservations
WHERE ReservationID = %s
"""
cursor.execute(query, (reservation_id,))
connection.commit()
cursor.close()
connection.close()
return {'message': 'Reservation removed successfully'}
except mysql.connector.Error as err:
print(f"Error removing reservation: {err}")
connection.rollback()
return {'error': f"Error removing reservation: {err}"}

def move_to_completed_reservations(reservation_id):
connection = get_db_connection(db_config)
if connection:
Expand All @@ -402,10 +421,7 @@ def move_to_completed_reservations(reservation_id):
)
cursor.execute(insert_query, values)

delete_query = """
DELETE FROM Reservations WHERE ReservationID = %s
"""
cursor.execute(delete_query, (reservation_id,))
remove_reservation_by_id(reservation_id)

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

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

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


@app.route('/api/remove-reservation/<string:chair_id>', methods=['DELETE'])
def remove_reservation_route(chair_id):
try:
Expand Down
2 changes: 1 addition & 1 deletion backend/db/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CREATE TABLE Reservations (
EndTime VARCHAR(225) NOT NULL,
Seat VARCHAR(50),
TableFee DECIMAL(10,2) DEFAULT 0.00,
FOREIGN KEY (UserID) REFERENCES Users(UserID) ON DELETE CASCADE
FOREIGN KEY (UserID) REFERENCES Users(UserID)

);

Expand Down

0 comments on commit 1374937

Please sign in to comment.