From 97a3b9f012bcfff9753e666d8bf54750bf72b320 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 28 Nov 2011 18:29:30 +0400 Subject: [PATCH] api: include labels to getHeadlines; optimize SQL queries for getHeadlines --- functions.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index d7fe0593..360a48ef 100644 --- a/functions.php +++ b/functions.php @@ -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); } -- 2.39.5