|
|
|
@ -56,45 +56,18 @@ class NetBiblio extends WebService
|
|
|
|
return $user;
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Retrive books from Solr based on their code (NoticeNr).
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param array $codes
|
|
|
|
|
|
|
|
* @return array Books information
|
|
|
|
|
|
|
|
* @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));
|
|
|
|
|
|
|
|
return $results['books'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Retrieve file information (samples and zip) for a list of books based
|
|
|
|
* Retrieve file information (samples and zip) for a list of books based
|
|
|
|
* on their code (NoticeNr).
|
|
|
|
* on their code (NoticeNr).
|
|
|
|
* This should be called only if those information are not already in Solr
|
|
|
|
* This should be called only if those information are not already in Solr
|
|
|
|
* for the given books.
|
|
|
|
* for the given books.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param array $ids
|
|
|
|
* @param array $codes
|
|
|
|
* @return array File information indexed by book code
|
|
|
|
* @return array File information indexed by book code
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function GetFiles(array $codes)
|
|
|
|
private function GetFiles(array $codes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$ids = array_map('intval', $codes);
|
|
|
|
$codes = array_map('intval', $codes);
|
|
|
|
|
|
|
|
|
|
|
|
$uri = sprintf("%s%s",
|
|
|
|
$uri = sprintf("%s%s",
|
|
|
|
Configuration::get('checkfile_url'),
|
|
|
|
Configuration::get('checkfile_url'),
|
|
|
|
|