From 30d670a5758d35d455d28758e3931b0e876f9ae9 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 9 May 2024 02:23:55 +0200 Subject: [PATCH] Grab page limit from scout config --- app/Member/Actions/ExportAction.php | 3 ++- app/Member/FilterScope.php | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Member/Actions/ExportAction.php b/app/Member/Actions/ExportAction.php index 357884fb..c15bbfea 100644 --- a/app/Member/Actions/ExportAction.php +++ b/app/Member/Actions/ExportAction.php @@ -6,6 +6,7 @@ use App\Member\FilterScope; use App\Member\Member; use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Facades\Storage; +use Laravel\Scout\EngineManager; use League\Csv\Writer; use Lorisleiva\Actions\ActionRequest; use Lorisleiva\Actions\Concerns\AsAction; @@ -43,7 +44,7 @@ class ExportAction public function asController(ActionRequest $request): StreamedResponse { - $members = FilterScope::fromRequest($request->input('filter'))->withOptions(['hitsPerPage' => 20000])->getQuery()->get(); + $members = FilterScope::fromRequest($request->input('filter'))->noPageLimit()->getQuery()->get(); $contents = $this->handle($members); Storage::disk('temp')->put('mitglieder.csv', $contents); diff --git a/app/Member/FilterScope.php b/app/Member/FilterScope.php index 6e97ceea..5f1e03fb 100644 --- a/app/Member/FilterScope.php +++ b/app/Member/FilterScope.php @@ -59,6 +59,13 @@ class FilterScope extends ScoutFilter return $this; } + public function noPageLimit(): self + { + return $this->withOptions([ + 'hitsPerPage' => config('scout.meilisearch.index-settings.' . Member::class . '.pagination.maxTotalHits') + ]); + } + public function getQuery(): Builder { $this->search = $this->search ?: '';