This commit is contained in:
parent
8708efece2
commit
b2fdc9a453
|
@ -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"]))
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user