From 34580189d982be9efba56e09707cda265fc4d57d Mon Sep 17 00:00:00 2001 From: Loki Sinclair Date: Thu, 24 Oct 2024 12:29:46 +0100 Subject: [PATCH 1/2] dirty hack for duplicate call to api with no title --- app/Http/Controllers/Api/V1/DatasetController.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/V1/DatasetController.php b/app/Http/Controllers/Api/V1/DatasetController.php index d2d23279b..9c27cfef6 100644 --- a/app/Http/Controllers/Api/V1/DatasetController.php +++ b/app/Http/Controllers/Api/V1/DatasetController.php @@ -135,9 +135,16 @@ public function index(Request $request): JsonResponse $datasetId = $request->query('dataset_id', null); $mongoPId = $request->query('mongo_pid', null); $withMetadata = $request->boolean('with_metadata', true); - + // apply any initial filters to get initial datasets + $filterTitle = $request->query('title', ''); $sort = $request->query('sort', 'created:desc'); + // Don't judge... I felt really dirty + if (isset($filterTitle) && $filterTitle === '') { + return response()->json([ + ], 200); + } + $tmp = explode(":", $sort); $sortField = $tmp[0]; $sortDirection = array_key_exists('1', $tmp) ? $tmp[1] : 'asc'; @@ -162,9 +169,6 @@ public function index(Request $request): JsonResponse ], 400); } - // apply any initial filters to get initial datasets - $filterTitle = $request->query('title', null); - $initialDatasets = Dataset::when($teamId, function ($query) use ($teamId) { return $query->where('team_id', '=', $teamId); })->when($datasetId, function ($query) use ($datasetId) { @@ -188,7 +192,7 @@ function ($query) use ($filterStatus) { $matches[] = $ds->id; } - if (!empty($filterTitle)) { + if (!empty($filterTitle) && $filterTitle !== '') { // If we've received a 'title' for the search, then only return // datasets that match that title $titleMatches = []; From db1a349f3f416280f45df6f1b175562283fa5027 Mon Sep 17 00:00:00 2001 From: Loki Sinclair Date: Thu, 24 Oct 2024 12:31:59 +0100 Subject: [PATCH 2/2] remove old code --- app/Http/Controllers/Api/V1/DatasetController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/V1/DatasetController.php b/app/Http/Controllers/Api/V1/DatasetController.php index 9c27cfef6..06c085999 100644 --- a/app/Http/Controllers/Api/V1/DatasetController.php +++ b/app/Http/Controllers/Api/V1/DatasetController.php @@ -192,7 +192,7 @@ function ($query) use ($filterStatus) { $matches[] = $ds->id; } - if (!empty($filterTitle) && $filterTitle !== '') { + if (!empty($filterTitle)) { // If we've received a 'title' for the search, then only return // datasets that match that title $titleMatches = [];