]> git.wh0rd.org Git - tt-rss.git/commitdiff
api: add getHeadlines since_id
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 9 Sep 2011 08:11:56 +0000 (12:11 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 9 Sep 2011 08:11:56 +0000 (12:11 +0400)
api/index.php
functions.php
modules/backend-rpc.php

index 55e60db291e2ae01c8f37c2610b1fa4143311c7e..737ce8abfbbe4b10d5455cac14506af0808f9994 100644 (file)
                        /* all_articles, unread, adaptive, marked, updated */
                        $view_mode = db_escape_string($_REQUEST["view_mode"]);
                        $include_attachments = (bool)db_escape_string($_REQUEST["include_attachments"]);
+                       $since_id = (int)db_escape_string($_REQUEST["since_id"]);
 
                        $headlines = api_get_headlines($link, $feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, false,
-                               $include_attachments);
+                               $include_attachments, $since_id);
 
                        print api_wrap_reply(API_STATUS_OK, $seq, $headlines);
 
index f0691f209e544683f53f254b0c97a1b8f1a43bed..48ab664c896212ca165bbb104caef39d3d50d99f 100644 (file)
        }
 
 
-       function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false) {
+       function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0) {
 
                if (!$owner_uid) $owner_uid = $_SESSION["uid"];
 
                                $filter_query_part = "";
                        }
 
+                       if ($since_id) {
+                               $since_id_part = "ttrss_entries.id > $since_id AND ";
+                       } else {
+                               $since_id_part = "";
+                       }
+
                        $view_query_part = "";
 
                        if ($view_mode == "adaptive" || $view_query_part == "noscores") {
                                        $search_query_part
                                        $filter_query_part
                                        $view_query_part
+                                       $since_id_part
                                        $query_strategy_part ORDER BY $order_by
                                        $limit_query_part $offset_query_part";
 
                                                                "link," .
                                                                "last_read," .
                                                                SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms," .
+                                                               $since_id_part .
                                                                $vfeed_query_part .
                                                                $content_query_part .
                                                                SUBSTRING_FOR_DATE . "(updated,1,19) as updated_noms," .
 
        function api_get_headlines($link, $feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
-                               $include_attachments) {
+                               $include_attachments, $since_id) {
 
                        /* do not rely on params below */
 
 
                        $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
                                $view_mode, $is_cat, $search, $search_mode, $match_on,
-                               $order, $offset);
+                               $order, $offset, 0, false, $since_id);
 
                        $result = $qfh_ret[0];
                        $feed_title = $qfh_ret[1];
index 6eea33df9d10c87d4c0d6b2ea8c91c38184e21fd..6cd9cd2d9c9b7b0f88af0abd82cfcf78f96deee3 100644 (file)
                        $reply['seq'] = $seq;
 
                        $headlines = api_get_headlines($link, $feed_id, 30, $offset,
-                               '', ($feed_id == -4), true, false, "unread", "updated DESC");
+                               '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
 
                        //function api_get_headlines($link, $feed_id, $limit, $offset,
                        //              $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {