array_agg
Some checks failed
Deploy on push / deploy (push) Failing after 8s

This commit is contained in:
Untone 2024-08-07 14:22:24 +03:00
parent 572f63f12b
commit 56c010975c

View File

@ -49,34 +49,34 @@ def query_shouts():
)
).label("rating_stat"),
func.max(aliased_reaction.created_at).label("last_reacted_at"),
func.json_agg(
func.json_build_object(
"id",
Author.id,
"name",
Author.name,
"slug",
Author.slug,
"pic",
Author.pic,
func.array_agg(
func.distinct(
func.json_build_object(
"id",
Author.id,
"name",
Author.name,
"slug",
Author.slug,
"pic",
Author.pic,
)
)
)
.filter(Author.id.is_not(None))
.label("authors"),
func.json_agg(
func.json_build_object(
"id",
Topic.id,
"title",
Topic.title,
"body",
Topic.body,
"slug",
Topic.slug,
).label("authors"),
func.array_agg(
func.distinct(
func.json_build_object(
"id",
Topic.id,
"title",
Topic.title,
"body",
Topic.body,
"slug",
Topic.slug,
)
)
)
.filter(Topic.id.is_not(None))
.label("topics"),
).label("topics"),
)
.outerjoin(aliased_reaction, aliased_reaction.shout == Shout.id)
.outerjoin(shout_author, shout_author.shout == Shout.id)
@ -84,7 +84,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, Author.id, Topic.id)
.group_by(Shout.id)
)
return q, aliased_reaction