From 7f7bf025e7bd86ec5f91afe57759c760baa1aaaf Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 14 Jan 2021 11:52:37 +0100 Subject: [PATCH] Fix leftovers Signed-off-by: Thomas Citharel --- lib/mobilizon/events/events.ex | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 9d6792940..d601fb8ff 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -520,7 +520,8 @@ defmodule Mobilizon.Events do |> events_for_tags(args) |> events_for_location(args) |> filter_local_or_from_followed_instances_events() - |> order_by([q], asc: q.id) + |> filter_public_visibility() + |> event_order_begins_on_asc() |> Page.build_page(page, limit) end @@ -1339,21 +1340,12 @@ defmodule Mobilizon.Events do end @spec events_for_search_query(String.t()) :: Ecto.Query.t() + defp events_for_search_query(""), do: Event + defp events_for_search_query(search_string) do - Event - |> where([e], e.visibility == ^:public) - |> distinct([e], e.id) - |> do_event_for_search_query(search_string) - end - - @spec do_event_for_search_query(Ecto.Query.t(), String.t()) :: Ecto.Query.t() - defp do_event_for_search_query(query, ""), do: query - - defp do_event_for_search_query(query, search_string) do - from(event in query, + from(event in Event, join: id_and_rank in matching_event_ids_and_ranks(search_string), - on: id_and_rank.id == event.id, - order_by: [desc: id_and_rank.rank] + on: id_and_rank.id == event.id ) end