This commit is contained in:
parent
a1486b3bba
commit
7b58c7537e
|
@ -20,10 +20,11 @@ from utils.logger import root_logger as logger
|
||||||
|
|
||||||
async def cache_by_id(entity, entity_id: int, cache_method):
|
async def cache_by_id(entity, entity_id: int, cache_method):
|
||||||
caching_query = select(entity).filter(entity.id == entity_id)
|
caching_query = select(entity).filter(entity.id == entity_id)
|
||||||
[x] = get_with_stat(caching_query)
|
result = get_with_stat(caching_query)
|
||||||
if not x:
|
if not result or not result[0]:
|
||||||
|
logger.warning(f"cache_by_id: {entity} with id {entity_id} not found")
|
||||||
return
|
return
|
||||||
|
x = result[0]
|
||||||
d = x.dict() # convert object to dictionary
|
d = x.dict() # convert object to dictionary
|
||||||
cache_method(d)
|
cache_method(d)
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Reference in New Issue
Block a user