diff --git a/module/VuFind/src/VuFind/ILS/Driver/Demo.php b/module/VuFind/src/VuFind/ILS/Driver/Demo.php index 61181aa59fbc0d55a425f02d384a0720a56e53e0..c9dddb70ae7a891d93c4c6842d48f00ad60beca1 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Demo.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Demo.php @@ -188,18 +188,6 @@ class Demo extends AbstractBase return $a.$b.".".$c; } - /** - * Set up the Solr index so we can retrieve some record data. - * - * @return void - */ - protected function prepSolr() - { - // Get the total # of records in the system - $result = $this->searchService->search('Solr', new Query('*:*')); - $this->totalRecords = $result->getTotal(); - } - /** * Get a random ID from the Solr index. * @@ -207,14 +195,9 @@ class Demo extends AbstractBase */ protected function getRandomBibId() { - // Let's keep away from both ends of the index, but only take any of the - // first 500 000 records to avoid slow Solr queries. - $position = rand()%(min(array(500000, $this->totalRecords-1))); - $result = $this->searchService->search( - 'Solr', new Query('*:*'), $position, 1 - ); + $result = $this->searchService->random('Solr', new Query(''), 1); if (count($result) === 0) { - throw new \Exception('Solr index is empty!'); + throw new \Exception('Problem retrieving random record.'); } return current($result->getRecords())->getUniqueId(); } @@ -289,10 +272,6 @@ class Demo extends AbstractBase // 90% of 1-9 (give or take some odd maths) $items = rand()%10 - 1; - // Do some initial work in solr so we aren't repeating it inside this - // loop. - $this->prepSolr(); - $requestGroups = $this->getRequestGroups(null, null); $list = new ArrayObject(); @@ -633,10 +612,6 @@ class Demo extends AbstractBase // 90% of 1-18 (give or take some odd maths) $fines = rand()%20 - 2; - // Do some initial work in solr so we aren't repeating it inside this - // loop. - $this->prepSolr(); - $fineList = array(); for ($i = 0; $i < $fines; $i++) { // How many days overdue is the item? @@ -744,10 +719,6 @@ class Demo extends AbstractBase // 90% of 1-9 (give or take some odd maths) $trans = rand()%10 - 1; - // Do some initial work in solr so we aren't repeating it inside this - // loop. - $this->prepSolr(); - $transList = array(); for ($i = 0; $i < $trans; $i++) { // When is it due? +/- up to 15 days @@ -1012,9 +983,6 @@ class Demo extends AbstractBase */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - // Do some initial work in solr so we aren't repeating it inside this loop. - $this->prepSolr(); - // Pick a random number of results to return -- don't exceed limit or 30, // whichever is smaller (this can be pretty slow due to the random ID code). $count = rand(0, $limit > 30 ? 30 : $limit); @@ -1048,9 +1016,6 @@ class Demo extends AbstractBase */ public function findReserves($course, $inst, $dept) { - // Do some initial work in solr so we aren't repeating it inside this loop. - $this->prepSolr(); - // Pick a random number of results to return -- don't exceed 30. $count = rand(0, 30); $results = array();