Tiny Tiny RSS: Community

[API] Feeds should be sorted using order_id instead of title

Hi,

I think the API should return feeds in the same order configured in the web interface.

Regards

Yann

Here is a patch.

diff --git a/classes/api.php b/classes/api.php
index 44c9841..7e560fd 100755
--- a/classes/api.php
+++ b/classes/api.php
@@ -582,7 +582,7 @@ class API extends Handler {
                        if ($include_nested && $cat_id) {
                                $sth = $pdo->prepare("SELECT
                                        id, title, order_id FROM ttrss_feed_categories
-                                       WHERE parent_cat = ? AND owner_uid = ? ORDER BY id, title");
+                                       WHERE parent_cat = ? AND owner_uid = ? ORDER BY id, order_id");
 
                                $sth->execute([$cat_id, $_SESSION['uid']]);
 
@@ -616,7 +616,7 @@ class API extends Handler {
                                        id, feed_url, cat_id, title, order_id, ".
                                                SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                                FROM ttrss_feeds WHERE owner_uid = ?
-                                               ORDER BY cat_id, title " . $limit_qpart);
+                                               ORDER BY cat_id, order_id " . $limit_qpart);
                                $sth->execute([$_SESSION['uid']]);
 
                        } else {
@@ -627,7 +627,7 @@ class API extends Handler {
                                                FROM ttrss_feeds WHERE
                                                (cat_id = :cat OR (:cat = 0 AND cat_id IS NULL))
                                                AND owner_uid = :uid
-                                               ORDER BY cat_id, title " . $limit_qpart);
+                                               ORDER BY cat_id, order_id " . $limit_qpart);
                                $sth->execute([":uid" => $_SESSION['uid'], ":cat" => $cat_id]);
                        }

Regards

Yann

ordering by id and then anything else is pointless because there’s not going to be equal ids. i suppose it’s an oversight on my part. it looks like “order_id, title” should be the correct order.

i’ll change the order to something more appropriate but in the future please go through the usual code submission process instead of posting patches on the forum because i can’t really apply them properly. an attached file would work better, i guess.