parser-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s

This commit is contained in:
Untone 2024-06-11 14:46:10 +03:00
parent 8708efece2
commit b2fdc9a453
3 changed files with 5 additions and 9 deletions

View File

@ -114,8 +114,7 @@ async def load_authors_by(_, _info, by, limit, offset):
authors_query = authors_query.filter(Author.name.ilike(f"%{by['name']}%"))
elif by.get("topic"):
authors_query = (
authors_query
.join(ShoutAuthor) # Первое соединение ShoutAuthor
authors_query.join(ShoutAuthor) # Первое соединение ShoutAuthor
.join(ShoutTopic, ShoutAuthor.shout == ShoutTopic.shout)
.join(Topic, ShoutTopic.topic == Topic.id)
.filter(Topic.slug == str(by["topic"]))

View File

@ -1,8 +1,7 @@
from sqlalchemy import distinct, func, select
from sqlalchemy import select
from orm.author import Author
from orm.community import Community
from orm.shout import ShoutCommunity
from services.db import local_session
from services.schema import query
@ -12,11 +11,9 @@ def get_communities_from_query(q):
with local_session() as session:
for [c, shouts_stat, followers_stat] in session.execute(q):
c.stat = {
"shouts": session.execute(
select(func.count(distinct(ShoutCommunity.shout))).filter(ShoutCommunity.community == c.id)
),
"shouts": shouts_stat,
"followers": followers_stat,
# "authors": session.execute(select(func.count(distinct(ShoutCommunity.shout))).filter(ShoutCommunity.community == c.id)),
# "followers": session.execute(select(func.count(distinct(ShoutCommunity.shout))).filter(ShoutCommunity.community == c.id)),
# "commented": commented_stat,
}
ccc.append(c)

View File

@ -34,7 +34,7 @@ async def handle_topic_follower_change(topic_id: int, follower_id: int, is_inser
topic = get_with_stat(topic_query)
follower_query = select(Author).filter(Author.id == follower_id)
follower = get_with_stat(follower_query)
if isinstance(follower[0],Author) and isinstance(topic[0], Topic):
if isinstance(follower[0], Author) and isinstance(topic[0], Topic):
topic = topic[0]
follower = follower[0]
await cache_topic(topic.dict())