feat(putTogether): read db also combined

This commit is contained in:
darkicewolf50 2024-11-30 15:35:56 -07:00
parent 838e53905a
commit 76632341e5
12 changed files with 37 additions and 23 deletions

View File

@ -1,6 +1,8 @@
import yaml
import json
from ReadDB import ReadDatabase
with open("./MockDB/schedule.yaml", "r") as scheduleyml:
ymlschedule = yaml.safe_load(scheduleyml)
@ -17,8 +19,7 @@ def getSchedulePackager():
``Contact``: darkicewolf50@gmail.ocm
"""
return {
"interviewDates": json.dumps(ymlschedule)
"interviewDates": ReadDatabase()
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -29,8 +29,8 @@ def get_root():
from GetSchedulePackager import getSchedulePackager
@app.get("/getSchedule")
async def getSchedule():
@app.get("/getAppointments")
async def getAppointments():
res = getSchedulePackager()

View File

@ -1,4 +1,5 @@
from WriteDB import AppendAppointment
from email_validator import validate_email, EmailNotValidError
def SelectAppointment (appointmentJson):
@ -15,17 +16,29 @@ def SelectAppointment (appointmentJson):
``Contact``: darkicewolf50@gmail.com
"""
"""
{
"intervieweeName": "Alice Johnson",
"date": "2024-09-16",
"startTime": "10:30:00",
"intervieweeEmail": "darkicewolf50@gmail.com"
}
"""
try:
validEmail = validate_email(appointmentJson["intervieweeEmail"], check_deliverability=True)
if validEmail:
status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
if status:
resBody = {"Success": True, "validEmail": "true"}
else:
resBody = {"Success": False, "validEmail": "true"}
status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
# resBody["message"] = appointmentJson for testing
return resBody
if status:
resBody = {"Success": True}
else:
resBody = {"Success": False}
# resBody["message"] = appointmentJson for testing
return resBody
except EmailNotValidError as e:
return {"Success": False, "validEmail": "false"}
if __name__ == "__main__":
print(SelectAppointment("10:00 AM"))

View File

@ -78,7 +78,7 @@ def send_email(interviewee_email="darkicewolf50@gmail.com", interviewee_name="br
server.login(gmail_user, gmail_apppassword)
server.sendmail(gmail_user, [interviewee_email, static_email], msg.as_string())
server.quit()
print(f"Email sent successfully to {interviewee_email} and {static_email}.")
# print(f"Email sent successfully to {interviewee_email} and {static_email}.")
except Exception as e:
print(f"Failed to send email: {e}")

View File

@ -8,18 +8,18 @@ def BenchMarkServer():
#print(json.dumps(res, indent=1))
def BenchMarkDjango():
rawRes = requests.get("http://localhost:8000/getSchedule")
rawRes = requests.get("http://127.0.0.1:8000/getAppointments")
res = json.loads(rawRes.text)
# print(json.dumps(res, indent=1))
#print(json.dumps(res, indent=1))
if __name__ == "__main__":
test = 0
test = 1
if test:
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10)
pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10)
print(f"FastAPI: {djangoTime}\nPython: {pythonTime}")
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=1000)
# pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10)
print(f"FastAPI: {djangoTime}\nPython: ")
reqbody = {
"body": {"message": "hello"}
}
rawRes = requests.post("http://localhost:8000/SelectInterview", reqbody)
# rawRes = requests.post("http://localhost:8000/SelectInterview", reqbody)