|
|
|
|
@ -64,6 +64,19 @@ class NetBiblio extends WebService
|
|
|
|
|
* @throws WebException
|
|
|
|
|
*/
|
|
|
|
|
private function GetBooks(array $codes) {
|
|
|
|
|
// 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;
|
|
|
|
|
$count = count($codes);
|
|
|
|
|
if(count($codes) > $limit) {
|
|
|
|
|
$parts = array_chunk($codes, $limit);
|
|
|
|
|
$books = array();
|
|
|
|
|
foreach($parts as $p) {
|
|
|
|
|
$books = array_merge($books, $this->GetBooks($p));
|
|
|
|
|
}
|
|
|
|
|
return $books;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$bs = new BookSearch();
|
|
|
|
|
$bs->addQuery('code:('.implode(' OR ', $codes).')', null, false);
|
|
|
|
|
$results = $bs->getResults(0, count($codes));
|
|
|
|
|
@ -398,23 +411,7 @@ class NetBiblio extends WebService
|
|
|
|
|
public function FindBooks($codes)
|
|
|
|
|
{
|
|
|
|
|
$this->CheckSession();
|
|
|
|
|
|
|
|
|
|
$codes = json_decode($codes);
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
return $this->AddBookData($this->GetBooks(json_decode($codes)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function FindBook($code)
|
|
|
|
|
|