From 42313184b02c001db657c0bdd142ea69fdb694ce Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 25 Feb 2024 11:35:06 +0300 Subject: [PATCH] import-fix --- resolvers/author.py | 2 +- resolvers/follower.py | 11 +++++++++-- services/event_listeners.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/resolvers/author.py b/resolvers/author.py index 6c10dd58..dc9d1272 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -126,7 +126,7 @@ def get_author_follows(_, _info, slug='', user=None, author_id=None): return { 'topics': topics, 'authors': authors, - 'communities': [{'id': 1, 'name': 'Дискурс', 'slug': 'discours'}], + 'communities': [{'id': 1, 'name': 'Дискурс', 'slug': 'discours', 'pic': ''}], } else: raise ValueError('Author not found') diff --git a/resolvers/follower.py b/resolvers/follower.py index c11b40ed..18e75969 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -13,7 +13,7 @@ from orm.shout import Shout, ShoutReactionsFollower from orm.topic import Topic, TopicFollower from resolvers.community import community_follow, community_unfollow from resolvers.topic import topic_follow, topic_unfollow -from resolvers.stat import get_with_stat, query_follows +from resolvers.stat import get_with_stat, author_follows_topics, author_follows_authors from services.auth import login_required from services.db import local_session from services.event_listeners import DEFAULT_FOLLOWS @@ -92,7 +92,14 @@ async def get_follows_by_user_id(user_id: str): day_old = int(time.time()) - author.get('last_seen', 0) > 24 * 60 * 60 if day_old: author_id = json.loads(str(author)).get('id') - follows = query_follows(author_id) + if author_id: + topics = author_follows_topics(author_id) + authors = author_follows_authors(author_id) + follows = { + 'topics': topics, + 'authors': authors, + 'communities': [{'id': 1, 'name': 'Дискурс', 'slug': 'discours', 'pic': ''}], + } else: logger.debug(f'getting follows for {user_id} from redis') res = await redis.execute('GET', f'user:{user_id}:follows') diff --git a/services/event_listeners.py b/services/event_listeners.py index 2ca03084..0e57f7b3 100644 --- a/services/event_listeners.py +++ b/services/event_listeners.py @@ -14,7 +14,7 @@ from services.rediscache import redis DEFAULT_FOLLOWS = { 'topics': [], 'authors': [], - 'communities': [{'slug': 'discours', 'name': 'Дискурс', 'id': 1, 'pic': ''}], + 'communities': [{'id': 1, 'name': 'Дискурс', 'slug': 'discours', 'pic': ''}], }