From: Andrew Dolgov Date: Wed, 12 Aug 2015 13:19:42 +0000 (+0300) Subject: pref-feeds: check for inactive feeds asynchronously X-Git-Tag: 16.3~146 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=f9c1f8b0d4e83d2984bcc0d60a0a0b3635459807;p=tt-rss.git pref-feeds: check for inactive feeds asynchronously --- diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 4194eda9..98eadf39 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1298,30 +1298,11 @@ class Pref_Feeds extends Handler_Protected { __("Feeds with errors") . ""; } - if (DB_TYPE == "pgsql") { - $interval_qpart = "NOW() - INTERVAL '3 months'"; - } else { - $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; - } - - // could be performance-intensive and prevent feeds pref-panel from showing - if (!defined('_DISABLE_INACTIVE_FEEDS') || !_DISABLE_INACTIVE_FEEDS) { - $result = $this->dbh->query("SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE - (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE - ttrss_entries.id = ref_id AND - ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND - ttrss_feeds.owner_uid = ".$_SESSION["uid"]); - - $num_inactive = $this->dbh->fetch_result($result, 0, "num_inactive"); - } else { - $num_inactive = 0; - } - - if ($num_inactive > 0) { - $inactive_button = ""; - } + $inactive_button = ""; $feed_search = $this->dbh->escape_string($_REQUEST["search"]); @@ -1433,6 +1414,8 @@ class Pref_Feeds extends Handler_Protected { "; @@ -1970,5 +1953,20 @@ class Pref_Feeds extends Handler_Protected { return $c; } + function getinactivefeeds() { + if (DB_TYPE == "pgsql") { + $interval_qpart = "NOW() - INTERVAL '3 months'"; + } else { + $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; + } + + $result = $this->dbh->query("SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE + (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE + ttrss_entries.id = ref_id AND + ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND + ttrss_feeds.owner_uid = ".$_SESSION["uid"]); + + print (int) $this->dbh->fetch_result($result, 0, "num_inactive"); + } } ?> diff --git a/js/prefs.js b/js/prefs.js index 67a4a378..159b9ecb 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -24,6 +24,20 @@ function updateFeedList(sort_key) { } }); } +function checkInactiveFeeds() { + try { + new Ajax.Request("backend.php", { + parameters: "?op=pref-feeds&method=getinactivefeeds", + onComplete: function(transport) { + if (parseInt(transport.responseText) > 0) { + Element.show(dijit.byId("pref_feeds_inactive_btn").domNode); + } + } }); + + } catch (e) { + exception_error("checkInactiveFeeds", e); + } +} function updateUsersList(sort_key) { try {