oneval-subq
Some checks failed
Deploy on push / deploy (push) Failing after 10s

This commit is contained in:
Untone 2024-10-31 14:50:45 +03:00
parent 5f2f4262a5
commit 6e56eba0c2

View File

@ -161,16 +161,11 @@ def get_shouts_with_stats(q, limit=20, offset=0, author_id=None):
select( select(
func.json_agg( func.json_agg(
func.json_build_object( func.json_build_object(
"id", "id", Author.id,
Author.id, "name", Author.name,
"name", "slug", Author.slug,
Author.name, "pic", Author.pic,
"slug", "caption", ShoutAuthor.caption,
Author.slug,
"pic",
Author.pic,
"caption",
ShoutAuthor.caption,
) )
).label("authors") ).label("authors")
) )
@ -186,10 +181,12 @@ def get_shouts_with_stats(q, limit=20, offset=0, author_id=None):
select( select(
func.json_agg( func.json_agg(
func.json_build_object( func.json_build_object(
"id", Topic.id, "title", Topic.title, "slug", Topic.slug, "is_main", ShoutTopic.main "id", Topic.id,
"title", Topic.title,
"slug", Topic.slug,
"is_main", ShoutTopic.main
) )
).label("topics"), ).label("topics"),
func.max(case((ShoutTopic.main, Topic.slug), else_=None)).label("main_topic_slug"),
) )
.select_from(ShoutTopic) .select_from(ShoutTopic)
.join(Topic, ShoutTopic.topic == Topic.id) .join(Topic, ShoutTopic.topic == Topic.id)