Skip to content

Commit

Permalink
doofinder/helpapp#3684 making sure scroll_id is always the last
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZ99 committed Apr 1, 2016
1 parent e145f36 commit 9f55fb9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/doofinder_management_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,18 @@ function __construct($searchEngine, $dType){
$this->searchEngine = $searchEngine;
}

function rewind() {
private function fetchResults(){
$apiResults = $this->searchEngine->getScrolledItemsPage($this->dType);
$this->total = $apiResults['total'];
$this->resultsPage = $apiResults['results'];
$this->scrollId = $apiResults['scroll_id'];
$this->currentItem = each($this->resultsPage);
}

function rewind() {
$this->fetchResults();
}

function valid(){
print "\nValid? ".$this->position.", ".$this->total;
return $this->position < $this->total;
Expand All @@ -399,9 +403,7 @@ function next(){
++$this->position;
$this->currentItem = each($this->resultsPage);
if(!$this->currentItem and $this->position < $this->total){
$this->resultsPage = $this->searchEngine->getScrolledItemsPage(
$this->dType, $this->scrollId
)['results'];
$this->fetchResults();
$this->currentItem = each($this->resultsPage);
}
}
Expand Down

0 comments on commit 9f55fb9

Please sign in to comment.