This commit is contained in:
parent
7cf702eb98
commit
9eee73acf3
|
@ -248,7 +248,7 @@ async def get_author_follows(
|
||||||
_, _info, slug="", user=None, author_id=None
|
_, _info, slug="", user=None, author_id=None
|
||||||
) -> List[Author]:
|
) -> List[Author]:
|
||||||
user_id = user
|
user_id = user
|
||||||
if author_id or slug:
|
if not user_id and author_id or slug:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
author = (
|
author = (
|
||||||
session.query(Author)
|
session.query(Author)
|
||||||
|
@ -258,8 +258,9 @@ async def get_author_follows(
|
||||||
user_id = author.user
|
user_id = author.user
|
||||||
|
|
||||||
if user_id:
|
if user_id:
|
||||||
follows = await get_follows_by_user_id(user)
|
follows = await get_follows_by_user_id(user_id)
|
||||||
return follows
|
return follows
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Author not found")
|
raise ValueError("Author not found")
|
||||||
|
|
||||||
|
|
|
@ -101,13 +101,21 @@ def query_follows(user_id: str):
|
||||||
.filter(TopicFollower.topic == Topic.id)
|
.filter(TopicFollower.topic == Topic.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
shouts_query = (
|
||||||
|
session.query(Shout, ShoutReactionsFollower)
|
||||||
|
.join(ShoutReactionsFollower, ShoutReactionsFollower.follower == author_id)
|
||||||
|
.filter(ShoutReactionsFollower.shout == Shout.id)
|
||||||
|
)
|
||||||
|
|
||||||
authors = set(session.execute(authors_query).scalars())
|
authors = set(session.execute(authors_query).scalars())
|
||||||
topics = set(session.execute(topics_query).scalars())
|
topics = set(session.execute(topics_query).scalars())
|
||||||
|
shouts = set(session.execute(shouts_query).scalars())
|
||||||
communities = session.query(Community).all()
|
communities = session.query(Community).all()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"topics": list(topics),
|
"topics": list(topics),
|
||||||
"authors": list(authors),
|
"authors": list(authors),
|
||||||
|
"shouts": list(shouts),
|
||||||
"communities": communities,
|
"communities": communities,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user