Merge branch 'v2' into dev
All checks were successful
Deploy on push / deploy (push) Successful in 26s
All checks were successful
Deploy on push / deploy (push) Successful in 26s
This commit is contained in:
commit
19d10b6219
|
@ -74,8 +74,8 @@ async def follow(_, info, what, slug):
|
||||||
await cache_topic(topic_dict)
|
await cache_topic(topic_dict)
|
||||||
|
|
||||||
elif what == "COMMUNITY":
|
elif what == "COMMUNITY":
|
||||||
# FIXME: when more communities
|
with local_session() as session:
|
||||||
follows = local_session().execute(select(Community))
|
follows = session.execute(select(Community))
|
||||||
|
|
||||||
elif what == "SHOUT":
|
elif what == "SHOUT":
|
||||||
error = reactions_follow(follower_id, slug)
|
error = reactions_follow(follower_id, slug)
|
||||||
|
@ -124,7 +124,8 @@ async def unfollow(_, info, what, slug):
|
||||||
await cache_topic(topic_dict)
|
await cache_topic(topic_dict)
|
||||||
|
|
||||||
elif what == "COMMUNITY":
|
elif what == "COMMUNITY":
|
||||||
follows = local_session().execute(select(Community))
|
with local_session() as session:
|
||||||
|
follows = session.execute(select(Community))
|
||||||
|
|
||||||
elif what == "SHOUT":
|
elif what == "SHOUT":
|
||||||
error = reactions_unfollow(follower_id, slug)
|
error = reactions_unfollow(follower_id, slug)
|
||||||
|
|
|
@ -327,7 +327,7 @@ async def load_shouts_unrated(_, info, limit: int = 50, offset: int = 0):
|
||||||
Reaction,
|
Reaction,
|
||||||
and_(
|
and_(
|
||||||
Reaction.shout == Shout.id,
|
Reaction.shout == Shout.id,
|
||||||
Reaction.replyTo.is_(None),
|
Reaction.reply_to.is_(None),
|
||||||
Reaction.kind.in_(
|
Reaction.kind.in_(
|
||||||
[ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]
|
[ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]
|
||||||
),
|
),
|
||||||
|
|
|
@ -52,7 +52,8 @@ def get_topic_shouts_stat(topic_id: int):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = local_session().execute(q).first()
|
with local_session() as session:
|
||||||
|
result = session.execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,8 +72,9 @@ def get_topic_authors_stat(topic_id: int):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Выполняем запрос и получаем результат
|
# Выполняем запрос и получаем результат
|
||||||
result = local_session().execute(count_query).scalar()
|
with local_session() as session:
|
||||||
return result if result is not None else 0
|
result = session.execute(count_query).first()
|
||||||
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
def get_topic_followers_stat(topic_id: int):
|
def get_topic_followers_stat(topic_id: int):
|
||||||
|
@ -80,7 +82,8 @@ def get_topic_followers_stat(topic_id: int):
|
||||||
q = select(func.count(distinct(aliased_followers.follower))).filter(
|
q = select(func.count(distinct(aliased_followers.follower))).filter(
|
||||||
aliased_followers.topic == topic_id
|
aliased_followers.topic == topic_id
|
||||||
)
|
)
|
||||||
result = local_session().execute(q).first()
|
with local_session() as session:
|
||||||
|
result = session.execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,8 +110,8 @@ def get_topic_comments_stat(topic_id: int):
|
||||||
ShoutTopic.topic == topic_id
|
ShoutTopic.topic == topic_id
|
||||||
)
|
)
|
||||||
q = q.outerjoin(sub_comments, ShoutTopic.shout == sub_comments.c.shout_id)
|
q = q.outerjoin(sub_comments, ShoutTopic.shout == sub_comments.c.shout_id)
|
||||||
|
with local_session() as session:
|
||||||
result = local_session().execute(q).first()
|
result = session.execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +145,8 @@ def get_author_authors_stat(author_id: int):
|
||||||
aliased_authors.author != author_id,
|
aliased_authors.author != author_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = local_session().execute(q).first()
|
with local_session() as session:
|
||||||
|
result = session.execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,7 +155,8 @@ def get_author_followers_stat(author_id: int):
|
||||||
q = select(func.count(distinct(aliased_followers.follower))).filter(
|
q = select(func.count(distinct(aliased_followers.follower))).filter(
|
||||||
aliased_followers.author == author_id
|
aliased_followers.author == author_id
|
||||||
)
|
)
|
||||||
result = local_session().execute(q).first()
|
with local_session() as session:
|
||||||
|
result = session.execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,8 +178,8 @@ def get_author_comments_stat(author_id: int):
|
||||||
.subquery()
|
.subquery()
|
||||||
)
|
)
|
||||||
q = select(sub_comments.c.comments_count).filter(sub_comments.c.id == author_id)
|
q = select(sub_comments.c.comments_count).filter(sub_comments.c.id == author_id)
|
||||||
|
with local_session() as session:
|
||||||
result = local_session().execute(q).first()
|
result = session.execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user