From 6917a390cfe7ff6c19a7d327ef51859faf8cacd0 Mon Sep 17 00:00:00 2001 From: darkicewolf50 Date: Sat, 22 Feb 2025 16:57:48 -0700 Subject: [PATCH] fix(master): found a bug and fixed datetime not match in cell --- InterviewBooking/ReadDB.py | 2 +- InterviewBooking/WriteDB.py | 4 +++- InterviewBooking/interviewPackagers.py | 5 ++++- main.py | 8 +++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/InterviewBooking/ReadDB.py b/InterviewBooking/ReadDB.py index 214d025..2ad7470 100644 --- a/InterviewBooking/ReadDB.py +++ b/InterviewBooking/ReadDB.py @@ -82,7 +82,7 @@ if __name__ == "__main__": year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season # name based off the 2025 naming system # Define the path to the Excel file and the lock file - file_name = f"./Interviews/OR{year_donation}-L-Interview Data.xlsx" + file_name = f"../Interviews/OR{year_donation}-L-Interview Data.xlsx" try: data = ReadDatabase(file_name) print(json.dumps(data, indent=4)) diff --git a/InterviewBooking/WriteDB.py b/InterviewBooking/WriteDB.py index ec4e50c..6ad22d2 100644 --- a/InterviewBooking/WriteDB.py +++ b/InterviewBooking/WriteDB.py @@ -1,5 +1,6 @@ import pandas as pd import json +import datetime from openpyxl import load_workbook from .send_email import send_email from filelock import FileLock @@ -33,7 +34,8 @@ def ReadDatabase(file_path, lock_path): # Process each row in the DataFrame to structure data by date and time for _, row in df.iterrows(): # Convert Date and Start Time to string format for easier comparison - date = str(row['Date']).split(" ")[0] # Format date to YYYY-MM-DD + date = str(row['Date']).split(" ")[0] # Extract the date part + start_time = str(row['Start Time Slot']) # Calculate the slot capacity and current number of interviewees diff --git a/InterviewBooking/interviewPackagers.py b/InterviewBooking/interviewPackagers.py index 88e0431..8fbe444 100644 --- a/InterviewBooking/interviewPackagers.py +++ b/InterviewBooking/interviewPackagers.py @@ -1,6 +1,8 @@ +import datetime from .ReadDB import ReadDatabase + def getSchedulePackager(file_name): """ Packages up the response for a http response @@ -39,7 +41,8 @@ def SelectAppointment (file_name, appointmentJson): try: validEmail = validate_email(appointmentJson["intervieweeEmail"], check_deliverability=True) if validEmail: - status = AppendAppointment(file_path=file_name, date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"]) + date_formatted = datetime.datetime.strptime(appointmentJson["date"], '%m/%d/%Y').strftime('%Y-%m-%d') + status = AppendAppointment(file_path=file_name, date=date_formatted, start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"]) if status: resBody = {"Success": True, "validEmail": "true"} diff --git a/main.py b/main.py index 89c3577..ba0d4c3 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ import os year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season # name based off the 2025 naming system # Define the path to the Excel file and the lock file -file_name = f"/Interviews/OR{year_donation}-L-Interview Data.xlsx" +file_name = f"./Interviews/OR{year_donation}-L-Interview Data.xlsx" if not os.path.isfile(file_name): os.makedirs(os.path.dirname(file_name), exist_ok=True) NoSheet(file_name) @@ -143,10 +143,9 @@ async def postSelectInterview(rawRequest: Appointment): ``Contact``: darkicewolf50@gmail.com """ - - requestDict = {key: str(value) for key, value in rawRequest.dict().items()} + requestDict = {key: str(value) for key, value in rawRequest.model_dump().items()} res = SelectAppointment(file_name, requestDict) - + return JSONResponse( headers={ "isBase64Encoded": "false", # Header Modification @@ -161,4 +160,3 @@ async def postSelectInterview(rawRequest: Appointment): # status_code=200 commented out just to show how to change it if you wanted ) -