22 lines
1.1 KiB
Python
22 lines
1.1 KiB
Python
from BreCal.database.sql_handler import execute_sql_query_standalone
|
|
import datetime
|
|
|
|
def get_user_data_for_id(user_id:int, expiration_time:int=90):
|
|
"""debugging function, which is useful to pull user_data from the database, which may be used to create stub data and unit tests"""
|
|
query = "SELECT * FROM user where id = ?id?"
|
|
pdata = execute_sql_query_standalone(query=query, param={"id":user_id})
|
|
pdata = pdata[0] if len(pdata)>0 else None
|
|
assert pdata is not None, f"could not find user with id {user_id}"
|
|
|
|
user_data = {k:v for k,v in pdata.items() if k in ['id','participant_id','first_name','last_name','user_name','user_phone','user_email']}
|
|
user_data["exp"] = (datetime.datetime.now()+datetime.timedelta(minutes=expiration_time)).timestamp()
|
|
return user_data
|
|
|
|
|
|
def get_times_data_for_id(times_id:int):
|
|
"""helper function to load previous times data from the database"""
|
|
query = "SELECT * FROM times where id = ?id?"
|
|
pdata = execute_sql_query_standalone(query=query, param={"id":times_id})
|
|
pdata = pdata[0] if len(pdata)>0 else None
|
|
assert pdata is not None, f"could not find times with id {times_id}"
|
|
return pdata |