Skip to content
Snippets Groups Projects
Commit 7542aa31 authored by Ere Maijala's avatar Ere Maijala
Browse files

Remove batch record loading support from Primo backend as it doesn't work...

Remove batch record loading support from Primo backend as it doesn't work properly (too many hits, a too long query will fail).
parent 263e1cb7
No related merge requests found
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
*/ */
namespace VuFindSearch\Backend\Primo; namespace VuFindSearch\Backend\Primo;
use VuFindSearch\Feature\RetrieveBatchInterface;
use VuFindSearch\Query\AbstractQuery; use VuFindSearch\Query\AbstractQuery;
use VuFindSearch\ParamBag; use VuFindSearch\ParamBag;
...@@ -49,7 +47,7 @@ use VuFindSearch\Backend\Exception\BackendException; ...@@ -49,7 +47,7 @@ use VuFindSearch\Backend\Exception\BackendException;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org * @link https://vufind.org
*/ */
class Backend extends AbstractBackend implements RetrieveBatchInterface class Backend extends AbstractBackend
{ {
/** /**
* Connector. * Connector.
...@@ -152,52 +150,6 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface ...@@ -152,52 +150,6 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface
return $collection; return $collection;
} }
/**
* Retrieve a batch of documents.
*
* @param array $ids Array of document identifiers
* @param ParamBag $params Search backend parameters
*
* @return RecordCollectionInterface
*/
public function retrieveBatch($ids, ParamBag $params = null)
{
$onCampus = (null !== $params) ? $params->get('onCampus') : [false];
$onCampus = $onCampus ? $onCampus[0] : false;
// Load 100 records at a time; this is a good number to avoid memory
// problems while still covering a lot of ground.
$pageSize = 100;
// Retrieve records a page at a time:
$results = false;
while (count($ids) > 0) {
$currentPage = array_splice($ids, 0, $pageSize, []);
try {
$response = $this->connector->getRecords(
$currentPage, $this->connector->getInstitutionCode(), $onCampus
);
} catch (\Exception $e) {
throw new BackendException(
$e->getMessage(),
$e->getCode(),
$e
);
}
$next = $this->createRecordCollection($response);
if (!$results) {
$results = $next;
} else {
foreach ($next->getRecords() as $record) {
$results->add($record);
}
}
}
$this->injectSourceIdentifier($results);
return $results;
}
/** /**
* Set the query builder. * Set the query builder.
* *
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment