User email look up improvement
This commit is contained in:
@@ -44,15 +44,15 @@ async def post_event_file_obj(
|
||||
|
||||
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def patch_event_file_obj(
|
||||
obj: Event_File_Base,
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
obj_id: str = Query(..., min_length=11, max_length=22),
|
||||
obj: Event_File_Base = None,
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
return_obj: Optional[bool] = True,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
obj_type = 'event_file'
|
||||
|
||||
@@ -495,7 +495,7 @@ async def get_event_session_obj(
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if event_session_id := redis_lookup_id_random(record_id_random=event_session_id, table_name='event_session'): pass
|
||||
|
||||
@@ -582,6 +582,8 @@ async def lookup_email(
|
||||
inc_contact: bool = False,
|
||||
inc_organization: bool = False,
|
||||
inc_person: bool = False,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
limit: int = 1,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = True,
|
||||
response: Response = Response,
|
||||
@@ -600,6 +602,22 @@ async def lookup_email(
|
||||
data = {}
|
||||
data['account_id'] = account_id
|
||||
data['email'] = email
|
||||
|
||||
if enabled in ['enabled', 'disabled', 'all']:
|
||||
if enabled == 'enabled':
|
||||
data['enable'] = True
|
||||
sql_enabled = f'AND `user`.enable = :enable'
|
||||
elif enabled == 'disabled':
|
||||
data['enable'] = False
|
||||
sql_enabled = f'AND `user`.enable = :enable'
|
||||
elif enabled == 'all':
|
||||
sql_enabled = ''
|
||||
else:
|
||||
return mk_resp(data=None, status_code=400, response=response) # Bad Request
|
||||
|
||||
data['limit'] = limit
|
||||
sql_limit = f'LIMIT :limit'
|
||||
|
||||
log.debug(data)
|
||||
|
||||
if account_id:
|
||||
@@ -607,12 +625,16 @@ async def lookup_email(
|
||||
SELECT id AS 'user_id', id_random AS 'user_id_random'
|
||||
FROM `user` AS `user`
|
||||
WHERE `user`.account_id = :account_id AND `user`.email = :email
|
||||
{sql_enabled}
|
||||
{sql_limit};
|
||||
"""
|
||||
else:
|
||||
sql = f"""
|
||||
SELECT id AS 'user_id', id_random AS 'user_id_random'
|
||||
FROM `user` AS `user`
|
||||
WHERE `user`.account_id IS NULL AND `user`.email = :email
|
||||
{sql_enabled}
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user