From 3b867ded203ae5e36a31bef808c58baf74f7dcc5 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 21 Feb 2024 13:51:07 +0300 Subject: [PATCH] redis-hset-fix --- orm/author.py | 4 ++-- resolvers/author.py | 2 +- resolvers/follower.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/orm/author.py b/orm/author.py index c09e3792..f2ea7856 100644 --- a/orm/author.py +++ b/orm/author.py @@ -48,7 +48,7 @@ class Author(Base): @event.listens_for(Author, "after_update") async def after_author_update(mapper, connection, target): redis_key = f"user:{target.user}:author" - await redis.execute("HSET", redis_key, vars(target)) + await redis.execute("HSET", redis_key, **vars(target)) async def update_follows_for_user(connection, user_id, entity_type, entity, is_insert): @@ -70,7 +70,7 @@ async def update_follows_for_user(connection, user_id, entity_type, entity, is_i e for e in follows[f"{entity_type}s"] if e["id"] != entity.id ] - await redis.execute("HSET", redis_key, vars(follows)) + await redis.execute("HSET", redis_key, **vars(follows)) async def handle_author_follower_change(connection, author_id, follower_id, is_insert): diff --git a/resolvers/author.py b/resolvers/author.py index 66e4c19e..bb6b1ef1 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -200,7 +200,7 @@ async def get_author_by_user_id(user_id: str): logger.info(f"getting author id for {user_id}") q = select(Author).filter(Author.user == user_id) author = await load_author_with_stats(q) - await redis.execute("HSET", redis_key, author.dict()) + await redis.execute("HSET", redis_key, **author.dict()) return author diff --git a/resolvers/follower.py b/resolvers/follower.py index 11819b64..87cca3df 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -137,7 +137,7 @@ async def get_follows_by_user_id(user_id: str): logger.debug(f"getting follows for {user_id}") follows = query_follows(user_id) - await redis.execute("HSET", redis_key, follows) + await redis.execute("HSET", redis_key, **follows) return follows