summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-01-18 10:18:09 +0100
committerAndrew Dolgov <[email protected]>2009-01-18 10:18:09 +0100
commit0112162d1a14aac7d9f2de09a1a528946cd73eb4 (patch)
treeb142cc223d990e78f691c0186581ea2616f0689a /functions.php
parent933ba4ee9c7c9f2cf5bcef5598272db8295a2157 (diff)
label counters: psql fix
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/functions.php b/functions.php
index 6cc801a0b..ef7802bf0 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");