Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Set reply sorting to 'oldest' #1035

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Bugfixes & Improvements
- Make 'text' field in 'comments' table NOT NULL and handling data migration (`#1019`_, pkvach)
- Python 3.12 support (`#1015`_, ix5)
- Disable Postbox submit button on click, enable after response (`#993`_, pkvach)
- Set reply sorting to always be oldest (`#1035`_, ggtylerr)

.. _#951: https://github.com/posativ/isso/pull/951
.. _#967: https://github.com/posativ/isso/pull/967
Expand All @@ -64,6 +65,7 @@ Bugfixes & Improvements
.. _#1019: https://github.com/isso-comments/isso/pull/1019
.. _#1015: https://github.com/isso-comments/isso/pull/1015
.. _#993: https://github.com/isso-comments/isso/pull/993
.. _#1035: https://github.com/isso-comments/isso/pull/1035

0.13.1.dev0 (2023-02-05)
------------------------
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/reference/client-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ data-isso-sorting
- ``oldest``: Bring oldest comments to the top
- ``upvotes``: Bring most liked comments to the top

Default sorting is ``oldest``.
Default sorting is ``oldest``. As of 0.13.1, replies are always sorted as
``oldest``.

.. versionadded:: 0.13.1

Expand Down
12 changes: 6 additions & 6 deletions isso/db/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,16 @@ 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 ')
sql.append("comments.created")
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 ')
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')
sql.append(", comments.created")
sql.append(', comments.created')

if limit:
sql.append('LIMIT ?,?')
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 ')
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