Skip to content

Commit

Permalink
Change sorting from id to created
Browse files Browse the repository at this point in the history
  • Loading branch information
ggtylerr committed Sep 3, 2024
1 parent 00eb569 commit 45103ba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions isso/db/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ def fetchall(self, mode=5, after=0, parent='any', order_by='id',

# custom sanitization
if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes', 'tid']:
sql.append('ORDER BY CASE WHEN comments.parent IS NOT NULL THEN comments.id END, ')
sql.append('ORDER BY CASE WHEN comments.parent IS NOT NULL THEN comments.created END, ')
sql.append('comments.created')
if not asc:
sql.append(' DESC')
else:
sql.append('ORDER BY CASE WHEN comments.parent IS NOT NULL THEN comments.id END, ')
sql.append('ORDER BY CASE WHEN comments.parent IS NOT NULL THEN comments.created END, ')
sql.append('comments.' + order_by)
if not asc:
sql.append(' DESC')
Expand Down Expand Up @@ -257,8 +257,8 @@ def fetch(self, uri, mode=5, after=0, parent='any',

# custom sanitization
if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes', 'karma']:
order_by = 'id'
sql.append('ORDER BY CASE WHEN comments.parent IS NOT NULL THEN comments.id END, ')
order_by = 'created'
sql.append('ORDER BY CASE WHEN comments.parent IS NOT NULL THEN comments.created END, ')
sql.append(order_by)
if not asc:
sql.append(' DESC')
Expand Down

0 comments on commit 45103ba

Please sign in to comment.