fmt
All checks were successful
Deploy on push / deploy (push) Successful in 24s

This commit is contained in:
2024-05-07 00:06:31 +03:00
parent e61db5d6e5
commit e0a5c654d8
9 changed files with 33 additions and 40 deletions

View File

@@ -11,12 +11,7 @@ from resolvers.author import ( # search_authors,
)
from resolvers.community import get_communities_all, get_community
from resolvers.editor import create_shout, delete_shout, update_shout
from resolvers.follower import (
follow,
get_shout_followers,
get_topic_followers,
unfollow,
)
from resolvers.follower import follow, get_shout_followers, get_topic_followers, unfollow
from resolvers.notifier import (
load_notifications,
notification_mark_seen,
@@ -40,12 +35,7 @@ from resolvers.reader import (
load_shouts_search,
load_shouts_unrated,
)
from resolvers.topic import (
get_topic,
get_topics_all,
get_topics_by_author,
get_topics_by_community,
)
from resolvers.topic import get_topic, get_topics_all, get_topics_by_author, get_topics_by_community
from services.triggers import events_register
events_register()

View File

@@ -315,10 +315,13 @@ async def get_author_followers(_, _info, slug: str):
if isinstance(cached, str):
followers_cached = json.loads(cached)
if isinstance(followers_cached, list):
logger.debug(f"@{slug} got {len(followers_cached)} followers cached")
logger.debug(
f"@{slug} got {len(followers_cached)} followers cached"
)
for fc in followers_cached:
if fc["id"] not in followers_ids:
if fc["id"] not in followers_ids and fc["id"] != author_id:
followers.append(fc)
followers_ids.append(fc["id"])
return followers
author_follower_alias = aliased(AuthorFollower, name="af")
@@ -327,12 +330,16 @@ async def get_author_followers(_, _info, slug: str):
and_(
author_follower_alias.author == author_id,
author_follower_alias.follower == Author.id,
Author.id != author_id, # exclude the author from the followers
),
)
results = get_with_stat(q)
if isinstance(results, list):
followers_ids = [r.id for r in results]
for follower in results:
await cache_follow_author_change(follower.dict(), author.dict())
if follower.id not in followers_ids:
await cache_follow_author_change(follower.dict(), author.dict())
followers_ids.append(follower.id)
logger.debug(f"@{slug} cache updated with {len(results)} followers")
return results
except Exception as exc:

View File

@@ -4,15 +4,15 @@ from sqlalchemy import and_, desc, select
from sqlalchemy.orm import joinedload
from sqlalchemy.sql.functions import coalesce
from orm.author import Author
from orm.rating import is_negative, is_positive
from orm.reaction import Reaction, ReactionKind
from orm.shout import Shout, ShoutAuthor, ShoutTopic
from orm.topic import Topic
from orm.author import Author
from resolvers.follower import reactions_follow, reactions_unfollow
from resolvers.stat import get_with_stat
from services.auth import login_required
from services.cache import cache_topic, cache_author
from services.cache import cache_author, cache_topic
from services.db import local_session
from services.diff import apply_diff, get_diff
from services.logger import root_logger as logger
@@ -99,7 +99,7 @@ async def get_shouts_drafts(_, info):
.group_by(Shout.id)
)
shouts = [shout for [shout] in session.execute(q).unique()]
return { "shouts": shouts }
return {"shouts": shouts}
@mutation.field("create_shout")

View File

@@ -8,12 +8,7 @@ from sqlalchemy.orm import aliased
from sqlalchemy.sql import not_
from orm.author import Author
from orm.notification import (
Notification,
NotificationAction,
NotificationEntity,
NotificationSeen,
)
from orm.notification import Notification, NotificationAction, NotificationEntity, NotificationSeen
from orm.shout import Shout
from services.auth import login_required
from services.db import local_session