api, getCategories: properly return information for categories with 0 feeds, but children categories present

This commit is contained in:
Andrew Dolgov 2013-03-24 14:46:45 +04:00
parent efc6553da4
commit 7be3fcd5e1
1 changed files with 5 additions and 2 deletions

View File

@ -133,7 +133,10 @@ class API extends Handler {
$result = db_query($this->link, "SELECT $result = db_query($this->link, "SELECT
id, title, order_id, (SELECT COUNT(id) FROM id, title, order_id, (SELECT COUNT(id) FROM
ttrss_feeds WHERE ttrss_feeds WHERE
ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds,
(SELECT COUNT(id) FROM
ttrss_feed_categories AS c2 WHERE
c2.parent_cat = ttrss_feed_categories.id) AS num_cats
FROM ttrss_feed_categories FROM ttrss_feed_categories
WHERE $nested_qpart AND owner_uid = " . WHERE $nested_qpart AND owner_uid = " .
$_SESSION["uid"]); $_SESSION["uid"]);
@ -141,7 +144,7 @@ class API extends Handler {
$cats = array(); $cats = array();
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
if ($line["num_feeds"] > 0) { if ($line["num_feeds"] > 0 || $line["num_cats"] > 0) {
$unread = getFeedUnread($this->link, $line["id"], true); $unread = getFeedUnread($this->link, $line["id"], true);
if ($enable_nested) if ($enable_nested)