Skip to content

Commit

Permalink
aggregated stats listings. docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZ99 committed Jul 17, 2016
1 parent 7d879e2 commit 4c011f9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,26 @@ $item = $items[4]; // WRONG!!!!!
PHP Fatal error: Cannot use object of type ItemsRS as array...
````

### Stats management ###
````php
<?php
date_default_timezone_set('America/Havana'); // some phps may need this
$from_date = new DateTime("2011-01-07");
$to_date = new DateTime("2011-02-07");
/* If not $from_date or $to_date provided, default is last 15 days */

$aggregates = $mySearchEngine->stats($from_date, $to_date);

foreach($aggregateds as $key => $aggregated){
echo $aggregated['date']; // date of the aggregated data
echo $aggregated['clicked']; // how many clicks in search results
echo $aggregated['searches'];// how many complete searches.i.e.: "mp3 player"
echo $aggregated['api']; // how many requests made through our API
echo $aggregated['parser']; // how many requests 'spent' in parsing feeds (1 per each 100 parsed items)
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
}
````

### Tasks management ###

Expand Down
14 changes: 14 additions & 0 deletions lib/doofinder_management_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,20 @@ function next(){
}
}

/**
* ScrollIterator
*
* Class to Iterate/Scroll through search engine's indexed items of a certain datatype
*/
class ScrollIterator extends ItemsRS {

private $scrollId = null;
private $dType = null;

/**
* @param SearchEngine $searchEngine
* @param string $dType type of item . i.e. 'product'
*/
function __construct($searchEngine, $dType){
$this->dType = $dType;
parent::__construct($searchEngine);
Expand Down Expand Up @@ -423,6 +432,11 @@ class AggregatesIterator extends ItemsRS {
protected $last_page = 0;
protected $searchParams = array();

/**
* @param SearchEngine $searchEngine
* @param DateTime $from_date . Starting date of the period. Default: 15 days ago
* @param DateTime $to_date. Ending date of the period. Default: today.
*/
function __construct($searchEngine, $from_date=null, $to_date=null){
$this->last_page = 0;
if($from_date!=null){
Expand Down

0 comments on commit 4c011f9

Please sign in to comment.