mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-23 15:01:28 +00:00
getLabelCounters: optimize SQL
This commit is contained in:
@@ -1413,15 +1413,18 @@
|
|||||||
|
|
||||||
$owner_uid = $_SESSION["uid"];
|
$owner_uid = $_SESSION["uid"];
|
||||||
|
|
||||||
$result = db_query($link, "SELECT id, caption FROM ttrss_labels2
|
$result = db_query($link, "SELECT id,caption,COUNT(unread) AS unread
|
||||||
WHERE owner_uid = '$owner_uid'");
|
FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON
|
||||||
|
(ttrss_labels2.id = label_id)
|
||||||
|
LEFT JOIN ttrss_user_entries ON (ref_id = article_id AND unread = true)
|
||||||
|
WHERE ttrss_labels2.owner_uid = $owner_uid GROUP BY ttrss_labels2.id");
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
$id = -$line["id"] - 11;
|
$id = -$line["id"] - 11;
|
||||||
|
|
||||||
$label_name = $line["caption"];
|
$label_name = $line["caption"];
|
||||||
$count = getFeedUnread($link, $id);
|
$count = $line["unread"];
|
||||||
|
|
||||||
$cv = array("id" => $id,
|
$cv = array("id" => $id,
|
||||||
"counter" => (int) $count);
|
"counter" => (int) $count);
|
||||||
|
|||||||
Reference in New Issue
Block a user