desc-order-fix

This commit is contained in:
2024-02-25 17:58:09 +03:00
parent 2e635abe5e
commit 309ac2d929
3 changed files with 6 additions and 6 deletions

View File

@@ -146,7 +146,7 @@ async def load_shouts_by(_, _info, options):
order_by = Shout.featured_at if filters.get('featured') else Shout.published_at
order_str = options.get('order_by')
if order_str in ['likes', 'shouts', 'followers', 'comments', 'last_comment']:
q = q.order_by(text(f'{order_str}_stat'))
q = q.order_by(desc(text(f'{order_str}_stat')))
query_order_by = (
desc(order_by) if options.get('order_by_desc', True) else asc(order_by)
)