Fix search event query

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-01-26 20:13:52 +01:00
parent 15fc036c1d
commit ba3e9fbaec
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -1340,10 +1340,14 @@ defmodule Mobilizon.Events do
end end
@spec events_for_search_query(String.t()) :: Ecto.Query.t() @spec events_for_search_query(String.t()) :: Ecto.Query.t()
defp events_for_search_query(""), do: Event defp events_for_search_query("") do
Event
|> distinct([e], e.id)
end
defp events_for_search_query(search_string) do defp events_for_search_query(search_string) do
from(event in Event, from(event in Event,
distinct: event.id,
join: id_and_rank in matching_event_ids_and_ranks(search_string), join: id_and_rank in matching_event_ids_and_ranks(search_string),
on: id_and_rank.id == event.id on: id_and_rank.id == event.id
) )