This commit is contained in:
parent
087f6a7157
commit
26d83aba7a
|
@ -10,7 +10,7 @@ from sqlalchemy.sql.expression import (
|
||||||
select,
|
select,
|
||||||
text,
|
text,
|
||||||
)
|
)
|
||||||
from sqlalchemy.dialects.postgresql import array_agg
|
from sqlalchemy.dialects.postgresql import json_agg
|
||||||
from orm.author import Author, AuthorFollower
|
from orm.author import Author, AuthorFollower
|
||||||
from orm.reaction import Reaction, ReactionKind
|
from orm.reaction import Reaction, ReactionKind
|
||||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutReactionsFollower
|
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutReactionsFollower
|
||||||
|
@ -48,32 +48,32 @@ def query_shouts():
|
||||||
)
|
)
|
||||||
).label("rating_stat"),
|
).label("rating_stat"),
|
||||||
func.max(aliased_reaction.created_at).label("last_reacted_at"),
|
func.max(aliased_reaction.created_at).label("last_reacted_at"),
|
||||||
array_agg(
|
json_agg(
|
||||||
func.distinct(
|
func.distinct(
|
||||||
func.json_build_object(
|
func.json_build_object(
|
||||||
"id",
|
"id",
|
||||||
Author.id,
|
Author.id,
|
||||||
"name",
|
"name",
|
||||||
Author.name,
|
Author.name,
|
||||||
"slug",
|
"slug",
|
||||||
Author.slug,
|
Author.slug,
|
||||||
"pic",
|
"pic",
|
||||||
Author.pic,
|
Author.pic,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).label("authors"),
|
).label("authors"),
|
||||||
array_agg(
|
json_agg(
|
||||||
func.distinct(
|
func.distinct(
|
||||||
func.json_build_object(
|
func.json_build_object(
|
||||||
"id",
|
"id",
|
||||||
Topic.id,
|
Topic.id,
|
||||||
"title",
|
"title",
|
||||||
Topic.title,
|
Topic.title,
|
||||||
"body",
|
"body",
|
||||||
Topic.body,
|
Topic.body,
|
||||||
"slug",
|
"slug",
|
||||||
Topic.slug,
|
Topic.slug,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).label("topics"),
|
).label("topics"),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user