]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Ticket #1987: support since_id on API notice search methods.
authorBrion Vibber <brion@status.net>
Fri, 19 Nov 2010 22:00:22 +0000 (14:00 -0800)
committerBrion Vibber <brion@status.net>
Fri, 19 Nov 2010 22:00:22 +0000 (14:00 -0800)
max_id is not yet implemented, as it'll need support added to the search backends. (since_id we get 'for free' by just cropping off the list, it'll do for now)

actions/apisearchatom.php
actions/apisearchjson.php
lib/jsonsearchresultslist.php

index 6743e92c84648ed8e3c13b862915cc59e9125557..32ff918da3b6e70e01966cece29d331372060691 100644 (file)
@@ -114,7 +114,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction
             $this->page = 1;
         }
 
-        // TODO: Suppport since_id -- we need to tweak the backend
+        // TODO: Suppport max_id -- we need to tweak the backend
         // Search classes to support it.
 
         $this->since_id = $this->trimmed('since_id');
@@ -177,6 +177,10 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction
                     $this->max_id = $notice->id;
                 }
 
+                if ($this->since_id && $notice->id <= $this->since_id) {
+                    break;
+                }
+
                 if ($cnt > $this->rpp) {
                     break;
                 }
index 38e612ee39d8cab25f6a11d1d32843746bd7fdeb..dd442b7f24925c5d99f50204d4ae0ec7eda044c7 100644 (file)
@@ -85,6 +85,9 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction
             $this->page = 1;
         }
 
+        // TODO: Suppport max_id -- we need to tweak the backend
+        // Search classes to support it.
+
         $this->since_id = $this->trimmed('since_id');
         $this->geocode  = $this->trimmed('geocode');
 
@@ -127,9 +130,9 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction
             $cnt = $notice->find();
         }
 
-        // TODO: since_id, lang, geocode
+        // TODO: max_id, lang, geocode
 
-        $results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page);
+        $results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page, $this->since_id);
 
         $this->initDocument('json');
         $results->show();
index 0d72ddf7ab48184e41c371407ae9efefe6c940ea..80d4036aad54694e851a4d84d6f2df215c5ddfe1 100644 (file)
@@ -101,6 +101,10 @@ class JSONSearchResultsList
                 $this->max_id = (int)$this->notice->id;
             }
 
+            if ($this->since_id && $this->notice->id <= $this->since_id) {
+                break;
+            }
+
             if ($cnt > $this->rpp) {
                 break;
             }