|
|
|
|
@ -212,16 +212,33 @@ class NetBiblio extends WebService
|
|
|
|
|
$this->getUser()->deleteWish($bookNr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function GetBooks(array $codes) {
|
|
|
|
|
$bs = new BookSearch();
|
|
|
|
|
$bs->addQuery('code:('.implode(' OR ', $codes).')', null, false);
|
|
|
|
|
$results = $bs->getResults(0, count($codes));
|
|
|
|
|
return $results['books'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function FindBooks($codes)
|
|
|
|
|
{
|
|
|
|
|
$this->CheckSession();
|
|
|
|
|
|
|
|
|
|
$codes = json_decode($codes);
|
|
|
|
|
$bs = new BookSearch();
|
|
|
|
|
$bs->addQuery('code:('.implode(' OR ', $codes).')', null, false);
|
|
|
|
|
$results = $bs->getResults(0, count($codes));
|
|
|
|
|
return $results['books'] ? $this->AddBookData($results['books']) : array();
|
|
|
|
|
|
|
|
|
|
// it is faster to do multiple small request to Solr rather than one big so separate
|
|
|
|
|
// in chunks if we are above the limit. 15 was found by testing and seems to be a sweet spot
|
|
|
|
|
$limit = 15;
|
|
|
|
|
if(count($codes) > $limit) {
|
|
|
|
|
$parts = array_chunk($codes, $limit);
|
|
|
|
|
$books = array();
|
|
|
|
|
foreach($parts as $p) {
|
|
|
|
|
$books = array_merge($books, $this->GetBooks($p));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$books = $this->GetBooks($codes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->AddBookData($books);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function GetFiles(array $ids)
|
|
|
|
|
@ -367,11 +384,7 @@ class NetBiblio extends WebService
|
|
|
|
|
public function FindBook($code)
|
|
|
|
|
{
|
|
|
|
|
$this->CheckSession();
|
|
|
|
|
|
|
|
|
|
$bs = new BookSearch();
|
|
|
|
|
$bs->addQuery($code, 'code');
|
|
|
|
|
$results = $bs->getResults(0, 1);
|
|
|
|
|
return $results['books'] ? reset($this->AddBookData($results['books'])) : null;
|
|
|
|
|
return reset($this->AddBookData($this->GetBooks(array($code))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetRandomBooks($number = 100, $seed = null) {
|
|
|
|
|
@ -381,8 +394,7 @@ class NetBiblio extends WebService
|
|
|
|
|
|
|
|
|
|
$bs = new BookSearch();
|
|
|
|
|
$bs->addSortField('random_'.$seed);
|
|
|
|
|
$results = $bs->getResults(0, $number);
|
|
|
|
|
return $results['books'] ? $this->AddBookData($results['books']) : array();
|
|
|
|
|
return $this->AddBookData($bs->getResults(0, $number));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Search($query, $start, $limit)
|
|
|
|
|
@ -470,11 +482,7 @@ class NetBiblio extends WebService
|
|
|
|
|
'facets' => $results['facets'],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if($results['books']) {
|
|
|
|
|
$data = array_merge($data, $this->AddBookData($results['books']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
return array_merge($data, $this->AddBookData($results['books']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ListOfReaders()
|
|
|
|
|
|