shouts-stat-fix
All checks were successful
Deploy on push / deploy (push) Successful in 27s

This commit is contained in:
Untone 2024-05-30 14:01:34 +03:00
parent a1ee49ba54
commit d54e2a2f3f
2 changed files with 7 additions and 3 deletions

View File

@ -73,7 +73,7 @@ async def follow(_, info, what, slug):
elif what == "COMMUNITY":
with local_session() as session:
follows = session.execute(select(Community))
follows = session.query(Community).all()
elif what == "SHOUT":
error = reactions_follow(follower_id, slug)

View File

@ -12,7 +12,9 @@ from services.logger import root_logger as logger
def add_topic_stat_columns(q):
aliased_shout = aliased(ShoutTopic)
q = q.outerjoin(aliased_shout).add_columns(func.count(distinct(aliased_shout.shout)).label("shouts_stat"))
q = q.outerjoin(aliased_shout, and_(aliased_shout.shout == Shout.id, Shout.deleted_at.is_(None))).add_columns(
func.count(distinct(aliased_shout.shout)).label("shouts_stat")
)
aliased_follower = aliased(TopicFollower)
q = q.outerjoin(aliased_follower, aliased_follower.topic == Topic.id).add_columns(
func.count(distinct(aliased_follower.follower)).label("followers_stat")
@ -25,7 +27,9 @@ def add_topic_stat_columns(q):
def add_author_stat_columns(q):
aliased_shout = aliased(ShoutAuthor)
q = q.outerjoin(aliased_shout).add_columns(func.count(distinct(aliased_shout.shout)).label("shouts_stat"))
q = q.outerjoin(aliased_shout, and_(aliased_shout.shout == Shout.id, Shout.deleted_at.is_(None))).add_columns(
func.count(distinct(aliased_shout.shout)).label("shouts_stat")
)
aliased_follower = aliased(AuthorFollower)
q = q.outerjoin(aliased_follower, aliased_follower.author == Author.id).add_columns(
func.count(distinct(aliased_follower.follower)).label("followers_stat")