[Patch] Update new feeds first on postgres

Development-related discussion, including bundled plugins
RoXX
Bear Rating Trainee
Bear Rating Trainee
Posts: 2
Joined: 31 Dec 2015, 15:04

[Patch] Update new feeds first on postgres

Postby RoXX » 31 Dec 2015, 15:25

Hi,

when the number of feeds is greater than DAEMON_UPDATE_LOGIN_LIMIT, newly added feeds are never updated.
The cause of this is that postgres by default treats NULL values as greater than everything and the feeds with NULL in last_updated are therefore always cut off by the limit statement.
This is easily fixed by adding 'NULLS FIRST' to the order query in postgres, changes to the mysql version are not needed.

I've added a proposed patch for this and would be willing to commit this as merge request, if you grant permissions to my gitlab account: RoXX

Patch:

Code: Select all

diff --git a/include/rssfuncs.php b/include/rssfuncs.php
index 56a16ec..380960b 100755
--- a/include/rssfuncs.php
+++ b/include/rssfuncs.php
@@ -134,6 +134,10 @@
                $query_limit = "";
                if($limit) $query_limit = sprintf("LIMIT %d", $limit);
 
+               // Update the least recently updated feeds first
+               $query_order = "ORDER BY last_updated";
+               if (DB_TYPE == "pgsql") $query_order .= " NULLS FIRST";
+
                $query = "SELECT DISTINCT ttrss_feeds.feed_url, ttrss_feeds.last_updated
                        FROM
                                ttrss_feeds, ttrss_users, ttrss_user_prefs
@@ -144,7 +148,7 @@
                                AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
                                $login_thresh_qpart $update_limit_qpart
                                $updstart_thresh_qpart
-                               ORDER BY last_updated $query_limit";
+                               $query_order $query_limit";
 
                // We search for feed needing update.
                $result = db_query($query);

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: [Patch] Update new feeds first on postgres

Postby fox » 31 Dec 2015, 16:30

i think you mean daemon_feed_limit? not sure how login days figures into this

other than that, makes sense, i guess, although i never ran into this myself

RoXX
Bear Rating Trainee
Bear Rating Trainee
Posts: 2
Joined: 31 Dec 2015, 15:04

Re: [Patch] Update new feeds first on postgres

Postby RoXX » 31 Dec 2015, 16:48

Yes, I meant DAEMON_FEED_LIMIT.

I ran into this with a user that is only accessing tt-rs through Mr. Reader on the iPad and only adding new feeds through bookmarklets.

I've submitted the merge request.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: [Patch] Update new feeds first on postgres

Postby fox » 31 Dec 2015, 17:58

merged

happy new year


Return to “Development”

Who is online

Users browsing this forum: No registered users and 3 guests