commit correcoes

This commit is contained in:
2026-11-21 20:58:19 +02:00
parent 4ca54e7655
commit 9d7a14459b
581 changed files with 151192 additions and 1620 deletions
+12 -3
View File
@@ -3,11 +3,14 @@
namespace App\Services;
use Illuminate\Database\QueryException;
use Symfony\Component\HttpKernel\Exception\HttpException;
/** Combines independent, already-authorised sources without loading complete catalogues. */
final class FederatedSearch
{
/** @param array<string, callable(): array{count:int, fetch:callable(int,int): iterable}> $factories */
/** @param array<string, callable(): array{count:int, fetch:callable(int,int): iterable<array<string,mixed>>}> $factories
* @return array{data:list<array<string,mixed>>,total:int,current_page:int,last_page:int,per_page:int,unavailable:list<string>}
*/
public function page(array $factories, int $requestedPage, int $size = 5, ?callable $score = null): array
{
$sources = [];
@@ -15,7 +18,10 @@ final class FederatedSearch
foreach ($factories as $label => $factory) {
try {
$sources[$label] = $factory();
} catch (QueryException $exception) {
} catch (QueryException|HttpException $exception) {
if ($exception instanceof HttpException && ! in_array($exception->getStatusCode(), [404, 503], true)) {
throw $exception;
}
report($exception);
$unavailable[] = $label;
}
@@ -45,7 +51,10 @@ final class FederatedSearch
if ($batch === []) {
$positions[$label] = $source['count'];
}
} catch (QueryException $exception) {
} catch (QueryException|HttpException $exception) {
if ($exception instanceof HttpException && ! in_array($exception->getStatusCode(), [404, 503], true)) {
throw $exception;
}
report($exception);
$unavailable[] = $label;
unset($sources[$label]);