0.4.1-following-update
This commit is contained in:
@@ -17,25 +17,24 @@ def add_topic_stat_columns(q):
|
||||
new_q = select(Topic)
|
||||
|
||||
# Apply the necessary filters to the new query object
|
||||
new_q = new_q.join(
|
||||
aliased_shout,
|
||||
aliased_shout.topic == Topic.id,
|
||||
).join(
|
||||
Shout,
|
||||
and_(
|
||||
aliased_shout.shout == Shout.id,
|
||||
Shout.deleted_at.is_(None),
|
||||
),
|
||||
).add_columns(
|
||||
func.count(distinct(aliased_shout.shout)).label("shouts_stat")
|
||||
new_q = (
|
||||
new_q.join(
|
||||
aliased_shout,
|
||||
aliased_shout.topic == Topic.id,
|
||||
)
|
||||
.join(
|
||||
Shout,
|
||||
and_(
|
||||
aliased_shout.shout == Shout.id,
|
||||
Shout.deleted_at.is_(None),
|
||||
),
|
||||
)
|
||||
.add_columns(func.count(distinct(aliased_shout.shout)).label("shouts_stat"))
|
||||
)
|
||||
|
||||
aliased_follower = aliased(TopicFollower)
|
||||
|
||||
new_q = new_q.outerjoin(
|
||||
aliased_follower,
|
||||
aliased_follower.topic == Topic.id
|
||||
).add_columns(
|
||||
new_q = new_q.outerjoin(aliased_follower, aliased_follower.topic == Topic.id).add_columns(
|
||||
func.count(distinct(aliased_follower.follower)).label("followers_stat")
|
||||
)
|
||||
|
||||
@@ -44,7 +43,6 @@ def add_topic_stat_columns(q):
|
||||
return new_q
|
||||
|
||||
|
||||
|
||||
def add_author_stat_columns(q):
|
||||
# Соединяем таблицу Author с таблицей ShoutAuthor и таблицей Shout с использованием INNER JOIN
|
||||
q = (
|
||||
|
Reference in New Issue
Block a user