This commit is contained in:
parent
dcd9f9e0bf
commit
6517fc9550
|
@ -48,33 +48,33 @@ 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"),
|
||||||
func.json_agg(
|
func.json_agg(
|
||||||
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"),
|
)
|
||||||
|
.filter(Author.id.is_not(None))
|
||||||
|
.label("authors"),
|
||||||
func.json_agg(
|
func.json_agg(
|
||||||
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"),
|
)
|
||||||
|
.filter(Topic.id.is_not(None))
|
||||||
|
.label("topics"),
|
||||||
)
|
)
|
||||||
.outerjoin(aliased_reaction, aliased_reaction.shout == Shout.id)
|
.outerjoin(aliased_reaction, aliased_reaction.shout == Shout.id)
|
||||||
.outerjoin(shout_author, shout_author.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(shout_topic, shout_topic.shout == Shout.id)
|
||||||
.outerjoin(Topic, Topic.id == shout_topic.topic)
|
.outerjoin(Topic, Topic.id == shout_topic.topic)
|
||||||
.where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None)))
|
.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
|
return q, aliased_reaction
|
||||||
|
|
Loading…
Reference in New Issue
Block a user