From c553d75cc94f40e1ca26b34cfcd52ac08f90967f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Wed, 13 Jun 2018 10:53:23 +0200 Subject: [PATCH] Fix sorting in /videos//comments API endpoint --- comments-api/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/comments-api/app.py b/comments-api/app.py index b6a3312..4d6f209 100644 --- a/comments-api/app.py +++ b/comments-api/app.py @@ -151,7 +151,9 @@ class CommentsResource(flask_restful.Resource): if args['sort_order'] == 'random': q = q.order_by(sqlalchemy.func.random()) elif args['sort_by']: - col = getattr(Comment, args['sort_by'], None) + col = getattr(Association, args['sort_by'], None) + if not col: + col = getattr(Comment, args['sort_by'], None) if col: if args['sort_order']: order_by = getattr(col, args['sort_order'], None)