This commit is contained in:
parent
11ea8b7efb
commit
dae2c7b689
|
@ -1,4 +1,4 @@
|
||||||
from sqlalchemy import func, distinct, select
|
from sqlalchemy import func, distinct, select, join
|
||||||
from sqlalchemy.orm import aliased
|
from sqlalchemy.orm import aliased
|
||||||
|
|
||||||
from orm.topic import TopicFollower, Topic
|
from orm.topic import TopicFollower, Topic
|
||||||
|
@ -71,23 +71,21 @@ def get_topics_with_stat(q):
|
||||||
|
|
||||||
|
|
||||||
def author_follows_authors(author_id: int):
|
def author_follows_authors(author_id: int):
|
||||||
aliased_author_authors = aliased(AuthorFollower, name="af")
|
af = aliased(AuthorFollower, name="af")
|
||||||
|
|
||||||
q = (
|
q = (
|
||||||
select(Author)
|
select(Author).select_from(
|
||||||
.join(aliased_author_authors, Author.id == aliased_author_authors.author)
|
join(Author, af, Author.id == af.author)
|
||||||
.filter(aliased_author_authors.follower == author_id)
|
).where(af.follower == author_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
q = add_author_stat_columns(q)
|
q = add_author_stat_columns(q)
|
||||||
return execute_with_ministat(q)
|
return execute_with_ministat(q)
|
||||||
|
|
||||||
|
|
||||||
def author_follows_topics(author_id: int):
|
def author_follows_topics(author_id: int):
|
||||||
q = (
|
q = (
|
||||||
select(Topic)
|
select(Topic).select_from(
|
||||||
.join(TopicFollower, Topic.id == TopicFollower.topic)
|
join(Topic, TopicFollower, Topic.id == TopicFollower.topic)
|
||||||
.filter(TopicFollower.follower == author_id)
|
).where(TopicFollower.follower == author_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
q = add_topic_stat_columns(q)
|
q = add_topic_stat_columns(q)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user