diff options
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-x | classes/feeds.php | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/classes/feeds.php b/classes/feeds.php index e1478a696..77add790e 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -457,8 +457,6 @@ class Feeds extends Handler_Protected { $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET last_read = NOW(), unread = false WHERE unread = true AND owner_uid = ?"); $sth->execute([$_SESSION['uid']]); - - CCache::zero_all($_SESSION["uid"]); } function view() { @@ -512,13 +510,6 @@ class Feeds extends Handler_Protected { return; } - /* Updating a label ccache means recalculating all of the caches - * so for performance reasons we don't do that here */ - - if ($feed >= 0) { - CCache::update($feed, $_SESSION["uid"], $cat_view); - } - set_pref("_DEFAULT_VIEW_MODE", $view_mode); set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by); @@ -791,16 +782,25 @@ class Feeds extends Handler_Protected { <!DOCTYPE html> <html> <head> - <?php echo stylesheet_tag("css/default.css") ?> <title>Feed Debugger</title> + <style type='text/css'> + @media (prefers-color-scheme: dark) { + body { + background : #222; + } + } + body.css_loading * { + display : none; + } + </style> <?php - echo stylesheet_tag("css/default.css"); echo javascript_tag("lib/prototype.js"); + echo javascript_tag("js/utility.js"); echo javascript_tag("lib/dojo/dojo.js"); echo javascript_tag("lib/dojo/tt-rss-layer.js"); ?> </head> - <body class="flat ttrss_utility feed_debugger"> + <body class="flat ttrss_utility feed_debugger css_loading"> <script type="text/javascript"> require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox', 'dijit/form/Form', 'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser, ready){ @@ -1004,8 +1004,6 @@ class Feeds extends Handler_Protected { } - CCache::update($feed, $owner_uid, $cat_view); - } else { // tag $sth = $pdo->prepare("UPDATE ttrss_user_entries SET unread = false, last_read = NOW() WHERE ref_id IN @@ -1292,7 +1290,8 @@ class Feeds extends Handler_Protected { } } - static function getCategoryUnread($cat, $owner_uid = false) { + // only real cats + static function getCategoryMarked($cat, $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -1300,46 +1299,48 @@ class Feeds extends Handler_Protected { if ($cat >= 0) { - if (!$cat) $cat = null; - - $sth = $pdo->prepare("SELECT id FROM ttrss_feeds + $sth = $pdo->prepare("SELECT SUM(CASE WHEN marked THEN 1 ELSE 0 END) AS marked + FROM ttrss_user_entries + WHERE feed_id IN (SELECT id FROM ttrss_feeds WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) - AND owner_uid = :uid"); + AND owner_uid = :uid) + AND owner_uid = :uid"); + $sth->execute(["cat" => $cat ? $cat : null, "uid" => $owner_uid]); + $row = $sth->fetch(); - $sth->execute([":cat" => $cat, ":uid" => $owner_uid]); + return $row["marked"]; + } else { + return 0; + } + } - $cat_feeds = array(); - while ($line = $sth->fetch()) { - array_push($cat_feeds, "feed_id = " . (int)$line["id"]); - } + static function getCategoryUnread($cat, $owner_uid = false) { - if (count($cat_feeds) == 0) return 0; + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; - $match_part = implode(" OR ", $cat_feeds); + $pdo = Db::pdo(); - $sth = $pdo->prepare("SELECT COUNT(int_id) AS unread - FROM ttrss_user_entries - WHERE unread = true AND ($match_part) - AND owner_uid = ?"); - $sth->execute([$owner_uid]); + if ($cat >= 0) { - $unread = 0; + $sth = $pdo->prepare("SELECT SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS unread + FROM ttrss_user_entries + WHERE feed_id IN (SELECT id FROM ttrss_feeds + WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) + AND owner_uid = :uid) + AND owner_uid = :uid"); + $sth->execute(["cat" => $cat ? $cat : null, "uid" => $owner_uid]); + $row = $sth->fetch(); - # this needs to be rewritten - while ($line = $sth->fetch()) { - $unread += $line["unread"]; - } + return $row["unread"]; - return $unread; } else if ($cat == -1) { - return getFeedUnread(-1) + getFeedUnread(-2) + getFeedUnread(-3) + getFeedUnread(0); + return 0; } else if ($cat == -2) { - $sth = $pdo->prepare("SELECT COUNT(unread) AS unread FROM - ttrss_user_entries, ttrss_user_labels2 - WHERE article_id = ref_id AND unread = true - AND ttrss_user_entries.owner_uid = ?"); - $sth->execute([$owner_uid]); + $sth = $pdo->prepare("SELECT COUNT(DISTINCT article_id) AS unread + FROM ttrss_user_entries ue, ttrss_user_labels2 l + WHERE article_id = ref_id AND unread IS true AND ue.owner_uid = :uid"); + $sth->execute(["uid" => $owner_uid]); $row = $sth->fetch(); return $row["unread"]; @@ -1372,12 +1373,14 @@ class Feeds extends Handler_Protected { $pdo = Db::pdo(); - $sth = $pdo->prepare("SELECT SUM(value) AS c_id FROM ttrss_counters_cache - WHERE owner_uid = ? AND feed_id > 0"); + $sth = $pdo->prepare("SELECT SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS count + FROM ttrss_user_entries ue + WHERE ue.owner_uid = ?"); + $sth->execute([$user_id]); $row = $sth->fetch(); - return $row["c_id"]; + return $row["count"]; } static function getCategoryTitle($cat_id) { @@ -2107,9 +2110,6 @@ class Feeds extends Handler_Protected { } if ($purge_interval == -1 || !$purge_interval) { - if ($owner_uid) { - CCache::update($feed_id, $owner_uid); - } return; } @@ -2154,8 +2154,6 @@ class Feeds extends Handler_Protected { $rows = $sth->rowCount(); - CCache::update($feed_id, $owner_uid); - Debug::log("Purged feed $feed_id ($purge_interval): deleted $rows articles"); return $rows; |