cache-follower-fix

This commit is contained in:
2024-05-06 10:25:09 +03:00
parent 0d87d3d889
commit a5d99fa517
3 changed files with 22 additions and 15 deletions

View File

@@ -325,7 +325,8 @@ async def get_author_followers(_, _info, slug: str):
else:
logger.debug(f"@{slug} got followers cached")
if isinstance(cached, str):
return json.loads(cached)
data = json.loads(cached)
return list(set(data))
except Exception as exc:
import traceback

View File

@@ -59,8 +59,8 @@ async def follow(_, info, what, slug):
[author] = get_with_stat(select(Author).filter(Author.slug == slug))
if author:
author_dict = author.dict()
author_id = int(author_dict.get('id', 0))
follows_ids = set(int(a.get('id')) for a in follows)
author_id = int(author_dict.get("id", 0))
follows_ids = set(int(a.get("id")) for a in follows)
if author_id not in follows_ids:
await cache_author(author_dict)
await cache_author(follower_dict)