debug-precache
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s

This commit is contained in:
Untone 2024-06-05 22:27:23 +03:00
parent 13e609bcf7
commit e942fdbffa

View File

@ -111,12 +111,14 @@ async def precache_data():
for author in authors: for author in authors:
profile = author.dict() if not isinstance(author, dict) else author profile = author.dict() if not isinstance(author, dict) else author
author_id = profile.get("id") author_id = profile.get("id")
if author_id: user_id = profile.get("user")
if author_id and user_id:
authors_by_id[author_id] = profile authors_by_id[author_id] = profile
user_id = profile["user"]
author_payload = json.dumps(profile, cls=CustomJSONEncoder) author_payload = json.dumps(profile, cls=CustomJSONEncoder)
await redis.execute("SET", f"author:id:{author_id}", author_payload) await redis.execute("SET", f"author:id:{author_id}", author_payload)
await redis.execute("SET", f"author:user:{user_id.strip()}", author_payload) await redis.execute("SET", f"author:user:{user_id.strip()}", author_payload)
else:
logger.error(f"caching {author.dict()}")
logger.info(f"{len(authors)} authors precached") logger.info(f"{len(authors)} authors precached")
# followings for authors # followings for authors