fix: returning a list of only count limit when codes count > limit
This commit is contained in:
@@ -289,21 +289,19 @@ class BookSearch
|
|||||||
// in chunks if we are above the limit. 15 was found by testing and seems to be a sweet spot
|
// in chunks if we are above the limit. 15 was found by testing and seems to be a sweet spot
|
||||||
$limit = 15;
|
$limit = 15;
|
||||||
$count = count($codes);
|
$count = count($codes);
|
||||||
if($count > $limit) {
|
|
||||||
$parts = array_chunk($codes, $limit);
|
|
||||||
$books = array();
|
|
||||||
foreach($parts as $p) {
|
|
||||||
// if we use array_merge here the numerical keys (book code) will be lost
|
|
||||||
$books += self::getBooks($p, $field);
|
|
||||||
}
|
|
||||||
return $books;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bs = self::getLastInstance();
|
$bs = self::getLastInstance();
|
||||||
|
$parts = $count <= $limit ? [$codes] : array_chunk($codes, $limit);
|
||||||
|
$books = [];
|
||||||
|
foreach($parts as $p) {
|
||||||
|
// if we use array_merge here the numerical keys (book code) will be lost
|
||||||
$bs->addOrQuery($codes, $field);
|
$bs->addOrQuery($codes, $field);
|
||||||
|
|
||||||
$results = $bs->getResults(0, $count);
|
$results = $bs->getResults(0, $count);
|
||||||
return $results['books'];
|
$foundBooks = $results['books'];
|
||||||
|
$books += $foundBooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $books;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTerms($field) {
|
public static function getTerms($field) {
|
||||||
|
|||||||
Reference in New Issue
Block a user