Skip to content

Commit

Permalink
managing not processed request
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZ99 committed Jul 18, 2016
1 parent bfbdef6 commit 456464a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,27 @@ foreach($aggregateds as $key => $aggregated){
echo $aggregated['queries']; // how many "raw" search request. i.e.: "mp3", "mp3 p", "mp3 pl" ..
echo $aggregated['requests']; // total number of requests for that day
}

$top_clicked = $mySearchEngine->top_terms('clicked', $from_date, $to_date);

foreach($top_clicked as $key => $clicked){
echo $clicked['term']; // title of the clicked item
echo $clicked['count']; // # of clicks on that item
}

$top_searches = $mySearchEngine->top_terms('searches', $from_date, $to_date);

foreach($top_searches as $key => $search){
echo $search['term']; // search terms used
echo $search['count']; // # of times it's been used
}

$top_opportunities = $mySearchEngine->top_terms('opportunities', $from_date, $to_date);

foreach($top_opportunities as $key => $opportunity){
echo $opportunity['term']; // search terms used (that haven't yielded any result)
echo $opportunity['count']; // # of times it's been used
}
````

### Tasks management ###
Expand Down
4 changes: 4 additions & 0 deletions lib/doofinder_management_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ protected function fetchResultsAndTotal(){
"{$this->searchEngine->hashid}/stats/top_{$this->term}",
array_merge($params, $this->searchParams)
);
// still generating?
if($apiResponse['statusCode'] == 202){
throw new NotProcessedResponse("Your request is still being processed. Please try again later");
}
$this->resultsPage = $apiResponse['response'][$this->term];
$this->total = $apiResponse['response']['count'];
$this->last_page++;
Expand Down
2 changes: 2 additions & 0 deletions lib/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class WrongResponse extends Exception {}

class ThrottledResponse extends Exception {}

class NotProcessedResponse extends Exception {}

function readError($response) {
$error = json_decode($response, true);
$error = $error['detail'];
Expand Down

0 comments on commit 456464a

Please sign in to comment.