api: include labels to getHeadlines; optimize SQL queries for getHeadlines

This commit is contained in:
Andrew Dolgov 2011-11-28 18:29:30 +04:00
parent 582f41e2c1
commit 97a3b9f012
1 changed files with 12 additions and 1 deletions

View File

@ -6921,6 +6921,12 @@
$is_updated = ($line["last_read"] == "" &&
($line["unread"] != "t" && $line["unread"] != "1"));
$tags = explode(",", $line["tag_cache"]);
$labels = json_decode($line["label_cache"], true);
//if (!$tags) $tags = get_article_tags($link, $line["id"]);
//if (!$labels) $labels = get_article_labels($link, $line["id"]);
$headline_row = array(
"id" => (int)$line["id"],
"unread" => sql_bool_to_bool($line["unread"]),
@ -6931,7 +6937,7 @@
"title" => $line["title"],
"link" => $line["link"],
"feed_id" => $line["feed_id"],
"tags" => get_article_tags($link, $line["id"]),
"tags" => $tags,
);
if ($include_attachments)
@ -6947,6 +6953,11 @@
$headline_row["content"] = $line["content_preview"];
}
// unify label output to ease parsing
if ($labels["no-labels"] == 1) $labels = array();
$headline_row["labels"] = $labels;
array_push($headlines, $headline_row);
}