Add distinct clause to search events

Closes #1174

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-10-25 10:36:37 +02:00
parent a1b439b724
commit 5225431d60
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -1272,16 +1272,11 @@ defmodule Mobilizon.Events do
end end
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 defp events_for_search_query(search_string) do
from(event in Event, Event
join: id_and_rank in matching_event_ids_and_ranks(search_string), |> distinct(:id)
on: id_and_rank.id == event.id |> join(:inner, [e], id_and_rank in matching_event_ids_and_ranks(search_string),
on: id_and_rank.id == e.id
) )
end end