diff --git a/app/Http/Controllers/HuntsController.php b/app/Http/Controllers/HuntsController.php index ae74bd5..6f85083 100644 --- a/app/Http/Controllers/HuntsController.php +++ b/app/Http/Controllers/HuntsController.php @@ -77,10 +77,15 @@ class HuntsController extends Controller $active = filter_var($request->query('active'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if ($active === true) { + // Hunt actif = démarré ET (pas terminé OU pas de date de fin) $filters[] = "start_at_timestamp <= {$now}"; - $filters[] = "(end_at_timestamp >= {$now} OR end_at_timestamp IS NULL)"; - } else { - $filters[] = "(start_at_timestamp > {$now} OR end_at_timestamp < {$now})"; + // Meilisearch : la syntaxe est 'field EXISTS' et non 'EXISTS field' + // Un hunt est actif si end_at_timestamp n'existe pas OU >= now + $filters[] = "(end_at_timestamp >= {$now} OR NOT end_at_timestamp EXISTS)"; + } elseif ($active === false) { + // Hunt non actif = pas encore commencé OU (déjà terminé ET a une date de fin) + // Si pas de end_at_timestamp, le hunt ne peut pas être terminé + $filters[] = "(start_at_timestamp > {$now} OR (end_at_timestamp < {$now} AND end_at_timestamp EXISTS))"; } }