From 4c011f9b61cd0899739f2d6ec655ac8347043a10 Mon Sep 17 00:00:00 2001 From: Joe Z Date: Sun, 17 Jul 2016 15:49:36 -0400 Subject: [PATCH] aggregated stats listings. docs --- README.md | 20 ++++++++++++++++++++ lib/doofinder_management_api.php | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/README.md b/README.md index 1967299..aacdaa1 100644 --- a/README.md +++ b/README.md @@ -491,6 +491,26 @@ $item = $items[4]; // WRONG!!!!! PHP Fatal error: Cannot use object of type ItemsRS as array... ```` +### Stats management ### +````php +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 ### diff --git a/lib/doofinder_management_api.php b/lib/doofinder_management_api.php index cc5bfe1..c5d920b 100644 --- a/lib/doofinder_management_api.php +++ b/lib/doofinder_management_api.php @@ -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); @@ -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){