ListOfDurations
This commit is contained in:
@@ -82,6 +82,11 @@ class BookSearch
|
||||
$this->query->addFacetField($field);
|
||||
}
|
||||
|
||||
public function setFacetRangeField($field)
|
||||
{
|
||||
$this->query->setParam('facet.range', $field);
|
||||
}
|
||||
|
||||
public function setFacetLimits($limit = null, $count = null)
|
||||
{
|
||||
if(! is_null($limit)) {
|
||||
@@ -93,6 +98,13 @@ class BookSearch
|
||||
}
|
||||
}
|
||||
|
||||
public function setFacetRange($start, $end, $gap)
|
||||
{
|
||||
$this->query->setParam('facet.range.start', $start);
|
||||
$this->query->setParam('facet.range.end', $end);
|
||||
$this->query->setParam('facet.range.gap', $gap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $start
|
||||
* @param int $count
|
||||
@@ -147,6 +159,19 @@ class BookSearch
|
||||
$facets[$f] = $d;
|
||||
}
|
||||
}
|
||||
if(isset($results['facet_counts']['facet_ranges'])) {
|
||||
$integer = strpos($this->query->getParam('facet.range.gap'), '.') === false;
|
||||
foreach($results['facet_counts']['facet_ranges'] as $f => $d) {
|
||||
if($integer) {
|
||||
$facets[$f] = array();
|
||||
foreach($d['counts'] as $k => $v) {
|
||||
$facets[$f][intval($k)] = $v;
|
||||
}
|
||||
} else {
|
||||
$facets[$f] = $d['counts'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'count' => $results['response']['numFound'],
|
||||
@@ -233,4 +258,27 @@ class BookSearch
|
||||
$results = $bs->getResults(0, $count);
|
||||
return $results['books'];
|
||||
}
|
||||
|
||||
public static function GetTerms($field) {
|
||||
$s = new BookSearch();
|
||||
$s->addQuery(1, 'visible');
|
||||
$s->addFacetField($field);
|
||||
$s->setFacetLimits(2000, 10);
|
||||
$results = $s->getResults(0, 0);
|
||||
|
||||
return $results['facets']['facets'][$field];
|
||||
}
|
||||
|
||||
|
||||
public static function GetTermsRange($field) {
|
||||
$s = new BookSearch();
|
||||
$s->addQuery(1, 'visible');
|
||||
$s->setFacetRangeField($field);
|
||||
$s->setFacetRange(0, 250, 1);
|
||||
// to avoid useless calculation, only set this 'normal' facet
|
||||
$s->addFacetField('visible');
|
||||
$results = $s->getResults(0, 0);
|
||||
|
||||
return $results['facets']['facets'][$field];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use BSR\Lib\WebService;
|
||||
class NetBiblio extends WebService
|
||||
{
|
||||
/** @var string $version version number */
|
||||
public static $version = '1.0.4';
|
||||
public static $version = '1.0.5';
|
||||
|
||||
private $login = '';
|
||||
private $client = 'website';
|
||||
@@ -721,6 +721,16 @@ class NetBiblio extends WebService
|
||||
return $bs->suggest($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the list of all volunteer readers that read book
|
||||
* in the database.
|
||||
* @return array
|
||||
*/
|
||||
public function ListOfDurations()
|
||||
{
|
||||
return BookSearch::GetTermsRange('duration');
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the list of all volunteer readers that read book
|
||||
* in the database.
|
||||
|
||||
Reference in New Issue
Block a user