@@ -207,19 +207,18 @@ async def get_comments(
207207 .filter (Comment .search_by_lectorer_id (lecturer_id ))
208208 .filter (Comment .search_by_user_id (user_id ))
209209 .order_by (
210- * (
211- Comment .order_by_create_ts (order_by , asc_order )
212- if "mark" in order_by
213- else Comment .order_by_mark (order_by , asc_order )
214- )
210+ Comment .order_by_create_ts (order_by , asc_order )
211+ if "mark" in order_by
212+ else Comment .order_by_mark (order_by , asc_order )
215213 )
216214 )
217-
215+
216+ print (comments_query .statement .compile ())
218217 comments = comments_query .limit (limit ).offset (offset ).all ()
219-
218+
220219 if not comments :
221220 raise ObjectNotFound (Comment , 'all' )
222- if user and "rating.comment.review" in [scope ['name' ] for scope in user .get ('session_scopes' )]:
221+ if "rating.comment.review" in [scope ['name' ] for scope in user .get ('session_scopes' )]:
223222 result = CommentGetAllWithAllInfo (limit = limit , offset = offset , total = len (comments ))
224223 comment_validator = CommentGetWithAllInfo
225224 elif user .get ('id' ) == user_id :
@@ -230,7 +229,7 @@ async def get_comments(
230229 comment_validator = CommentGet
231230
232231 result .comments = comments
233-
232+
234233 if unreviewed :
235234 if not user :
236235 raise ForbiddenAction (Comment )
@@ -244,7 +243,6 @@ async def get_comments(
244243 raise ForbiddenAction (Comment )
245244 else :
246245 result .comments = [comment for comment in result .comments if comment .review_status is ReviewStatus .APPROVED ]
247- result .comments = result .comments [offset : limit + offset ]
248246
249247 result .total = len (result .comments )
250248 result .comments = [comment_validator .model_validate (comment ) for comment in result .comments ]
0 commit comments