This commit is contained in:
parent
3a0683137d
commit
28f1f1cc57
1
main.py
1
main.py
|
@ -4,6 +4,7 @@ from os.path import exists
|
|||
|
||||
from ariadne import load_schema_from_path, make_executable_schema
|
||||
from ariadne.asgi import GraphQL
|
||||
|
||||
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
||||
from sentry_sdk.integrations.ariadne import AriadneIntegration
|
||||
from sentry_sdk.integrations.redis import RedisIntegration
|
||||
|
|
|
@ -380,18 +380,14 @@ async def load_reactions_by(_, info, by, limit=50, offset=0):
|
|||
q = apply_reaction_filters(by, q)
|
||||
q = q.where(Reaction.deleted_at.is_(None))
|
||||
|
||||
# group by
|
||||
q = q.group_by(Reaction.id, Author.id, Shout.id, aliased_reaction.created_at)
|
||||
|
||||
# order by
|
||||
order_way = asc
|
||||
order_field = by.get("sort", "").replace("-", "")
|
||||
if by.get("sort", "").startswith("-"):
|
||||
order_way = desc
|
||||
if not order_field:
|
||||
order_field = "created_at"
|
||||
order_way = desc
|
||||
q = q.order_by(order_way(order_field))
|
||||
order_value = by.get("sort", "-created_at")
|
||||
order_way = desc if order_value.startswith("-") else asc
|
||||
order_field = order_value.replace("-", "")
|
||||
# group by
|
||||
q = q.group_by(Reaction.id, Author.id, Shout.id, aliased_reaction.created_at, Reaction[order_field]).order_by(
|
||||
order_way(order_field)
|
||||
)
|
||||
|
||||
# pagination
|
||||
q = q.limit(limit).offset(offset)
|
||||
|
|
Loading…
Reference in New Issue
Block a user