This commit is contained in:
parent
2f81a5cf12
commit
f16f345040
|
@ -164,6 +164,7 @@ def author_follows_authors(author_id: int):
|
||||||
|
|
||||||
return authors
|
return authors
|
||||||
|
|
||||||
|
|
||||||
def author_follows_topics(author_id: int):
|
def author_follows_topics(author_id: int):
|
||||||
subquery_shout_topic = (
|
subquery_shout_topic = (
|
||||||
select(
|
select(
|
||||||
|
@ -202,31 +203,30 @@ def author_follows_topics(author_id: int):
|
||||||
select(
|
select(
|
||||||
[
|
[
|
||||||
Topic,
|
Topic,
|
||||||
func.coalesce(subquery_shout_topic.columns.shouts_stat, 0).label('shouts_stat'),
|
subquery_shout_topic.columns.shouts_stat,
|
||||||
func.coalesce(subquery_shout_topic_authors.columns.authors_stat, 0).label('authors_stat'),
|
subquery_shout_topic_authors.columns.authors_stat,
|
||||||
func.coalesce(subquery_topic_followers.columns.followers_stat, 0).label('followers_stat'),
|
subquery_topic_followers.columns.followers_stat,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
.select_from(Topic)
|
.select_from(Topic)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
subquery_shout_topic,
|
subquery_shout_topic,
|
||||||
Topic.id == subquery_shout_topic.columns.topic,
|
Topic.id == subquery_shout_topic.c.topic,
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
subquery_shout_topic_authors,
|
subquery_shout_topic_authors,
|
||||||
Topic.id == subquery_shout_topic_authors.columns.topic,
|
Topic.id == subquery_shout_topic_authors.c.topic,
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
subquery_topic_followers,
|
subquery_topic_followers,
|
||||||
Topic.id == subquery_topic_followers.columns.topic,
|
Topic.id == subquery_topic_followers.c.topic,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
topics = execute_with_ministat(topics_query)
|
topics = execute_with_ministat(topics_query)
|
||||||
return topics
|
return topics
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def query_follows(author_id: int):
|
def query_follows(author_id: int):
|
||||||
try:
|
try:
|
||||||
topics = author_follows_topics(author_id)
|
topics = author_follows_topics(author_id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user