This commit is contained in:
parent
b72ef072e4
commit
12439b6ef2
|
@ -28,7 +28,7 @@ async def cache_topic(topic: dict):
|
|||
|
||||
async def cache_author(author: dict):
|
||||
author_id = author.get("id")
|
||||
user_id = author.get("user")
|
||||
user_id = author.get("user", "").strip()
|
||||
payload = json.dumps(author, cls=CustomJSONEncoder)
|
||||
await redis.execute("SET", f"author:user:{user_id}", payload)
|
||||
await redis.execute("SET", f"author:id:{author_id}", payload)
|
||||
|
@ -76,7 +76,7 @@ async def get_cached_author(author_id: int, get_with_stat):
|
|||
|
||||
|
||||
async def get_cached_author_by_user_id(user_id: str, get_with_stat) -> dict:
|
||||
author_str = await redis.execute("GET", f"author:user:{user_id}")
|
||||
author_str = await redis.execute("GET", f"author:user:{user_id.strip()}")
|
||||
author_dict = None
|
||||
if not author_str:
|
||||
author_query = select(Author).filter(Author.user == user_id)
|
||||
|
|
|
@ -111,7 +111,7 @@ async def precache_data():
|
|||
for author in authors:
|
||||
profile = author.dict() if not isinstance(author, dict) else author
|
||||
author_id = profile.get("id")
|
||||
user_id = profile.get("user")
|
||||
user_id = profile.get("user","").strip()
|
||||
if author_id and user_id:
|
||||
authors_by_id[author_id] = profile
|
||||
author_payload = json.dumps(profile, cls=CustomJSONEncoder)
|
||||
|
|
Loading…
Reference in New Issue
Block a user