From 0112162d1a14aac7d9f2de09a1a528946cd73eb4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 18 Jan 2009 10:18:09 +0100 Subject: [PATCH] label counters: psql fix --- functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions.php b/functions.php index 6cc801a0..ef7802bf 100644 --- a/functions.php +++ b/functions.php @@ -2221,12 +2221,10 @@ } else if ($feed < -10) { // label - // TODO make this more efficient - $label_id = -$feed - 11; db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2 - SET unread = false WHERE label_id = '$label_id' + SET unread = false WHERE label_id = '$label_id' AND unread = true AND owner_uid = '".$_SESSION["uid"]."' AND ref_id = article_id"); } @@ -2413,10 +2411,11 @@ if (!$owner_uid) $owner_uid = $_SESSION["uid"]; $result = db_query($link, " - SELECT SUM(unread) AS unread FROM + SELECT COUNT(unread) AS unread FROM ttrss_user_entries, ttrss_labels2, ttrss_user_labels2 WHERE label_id = id AND article_id = ref_id AND ttrss_labels2.owner_uid = '$owner_uid' AND id = '$label_id' + AND unread = true AND ttrss_user_entries.owner_uid = '$owner_uid'"); if (db_num_rows($result) != 0) { @@ -2653,9 +2652,10 @@ $owner_uid = $_SESSION["uid"]; $result = db_query($link, - "SELECT id, caption, SUM(unread) AS unread FROM ttrss_labels2 + "SELECT id, caption, COUNT(unread) AS unread FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON (label_id = id) LEFT JOIN ttrss_user_entries ON (ref_id = article_id AND + unread = true AND ttrss_user_entries.owner_uid = '$owner_uid') WHERE ttrss_labels2.owner_uid = '$owner_uid' GROUP BY id"); -- 2.39.5