]> git.wh0rd.org Git - tt-rss.git/commitdiff
api: include labels to getHeadlines; optimize SQL queries for getHeadlines
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 28 Nov 2011 14:29:30 +0000 (18:29 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 28 Nov 2011 14:38:10 +0000 (18:38 +0400)
functions.php

index d7fe05932c67b296eebce995b0833bda0d0a7bea..360a48efdeb270d0cfd22bedb15b7933e8561393 100644 (file)
                                $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"]),
                                                "title" => $line["title"],
                                                "link" => $line["link"],
                                                "feed_id" => $line["feed_id"],
-                                               "tags" => get_article_tags($link, $line["id"]),
+                                               "tags" => $tags,
                                        );
 
                                        if ($include_attachments)
                                        $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);
                        }