groupby
Some checks failed
Deploy on push / deploy (push) Failing after 9s

This commit is contained in:
Untone 2024-08-07 13:57:37 +03:00
parent dcd9f9e0bf
commit 6517fc9550

View File

@ -48,7 +48,6 @@ def query_shouts():
).label("rating_stat"),
func.max(aliased_reaction.created_at).label("last_reacted_at"),
func.json_agg(
func.distinct(
func.json_build_object(
"id",
Author.id,
@ -60,9 +59,9 @@ def query_shouts():
Author.pic,
)
)
).label("authors"),
.filter(Author.id.is_not(None))
.label("authors"),
func.json_agg(
func.distinct(
func.json_build_object(
"id",
Topic.id,
@ -74,7 +73,8 @@ def query_shouts():
Topic.slug,
)
)
).label("topics"),
.filter(Topic.id.is_not(None))
.label("topics"),
)
.outerjoin(aliased_reaction, aliased_reaction.shout == Shout.id)
.outerjoin(shout_author, shout_author.shout == Shout.id)
@ -82,7 +82,7 @@ def query_shouts():
.outerjoin(shout_topic, shout_topic.shout == Shout.id)
.outerjoin(Topic, Topic.id == shout_topic.topic)
.where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None)))
.group_by(Shout.id)
.group_by(Shout.id, Author.id, Topic.id)
)
return q, aliased_reaction