From 5225431d60959dfdce7515eb96dd75f0861d0bb7 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 25 Oct 2022 10:36:37 +0200 Subject: [PATCH] Add distinct clause to search events Closes #1174 Signed-off-by: Thomas Citharel --- lib/mobilizon/events/events.ex | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 34034989..95234053 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -1272,16 +1272,11 @@ defmodule Mobilizon.Events do end end - # @spec events_for_search_query(String.t()) :: Ecto.Query.t() - # defp events_for_search_query("") do - # Event - # |> join: rank in fragment("") - # end - defp events_for_search_query(search_string) do - from(event in Event, - join: id_and_rank in matching_event_ids_and_ranks(search_string), - on: id_and_rank.id == event.id + Event + |> distinct(:id) + |> join(:inner, [e], id_and_rank in matching_event_ids_and_ranks(search_string), + on: id_and_rank.id == e.id ) end