Handle events with no physical location
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
4f1465e84d
commit
f0c8fa2525
@ -222,26 +222,6 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
|||||||
{:ok, events}
|
{:ok, events}
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec organizer_next_public_event(Event.t()) :: list(Event.t())
|
|
||||||
defp organizer_next_public_event(%Event{attributed_to: %Actor{} = group, uuid: uuid}) do
|
|
||||||
[Events.get_upcoming_public_event_for_actor(group, uuid)]
|
|
||||||
|> Enum.filter(&is_map/1)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp organizer_next_public_event(%Event{organizer_actor: %Actor{} = profile, uuid: uuid}) do
|
|
||||||
[Events.get_upcoming_public_event_for_actor(profile, uuid)]
|
|
||||||
|> Enum.filter(&is_map/1)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec similar_events_common_tags(list(Event.t()), Event.t()) :: list(Event.t())
|
|
||||||
defp similar_events_common_tags(events, %Event{tags: tags, uuid: uuid}) do
|
|
||||||
events
|
|
||||||
|> Enum.concat(Events.list_events_by_tags(tags, @number_of_related_events))
|
|
||||||
|> Enum.filter(fn event -> event.uuid != uuid end)
|
|
||||||
# uniq_by : It's possible event_from_same_actor is inside events_from_tags
|
|
||||||
|> uniq_events()
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec add_latest_events(list(Event.t())) :: list(Event.t())
|
@spec add_latest_events(list(Event.t())) :: list(Event.t())
|
||||||
defp add_latest_events(events) do
|
defp add_latest_events(events) do
|
||||||
if @number_of_related_events - length(events) > 0 do
|
if @number_of_related_events - length(events) > 0 do
|
||||||
|
@ -1691,11 +1691,12 @@ defmodule Mobilizon.Events do
|
|||||||
def related_events(%Event{
|
def related_events(%Event{
|
||||||
id: event_id,
|
id: event_id,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
physical_address: %Address{geom: geom},
|
physical_address: physical_address,
|
||||||
category: category,
|
category: category,
|
||||||
language: language
|
language: language
|
||||||
}) do
|
}) do
|
||||||
event_tags_ids = Enum.map(tags, & &1.id)
|
event_tags_ids = Enum.map(tags, & &1.id)
|
||||||
|
geom = if is_nil(physical_address), do: nil, else: physical_address.geom
|
||||||
|
|
||||||
Event
|
Event
|
||||||
|> distinct([e], e.id)
|
|> distinct([e], e.id)
|
||||||
@ -1704,14 +1705,14 @@ defmodule Mobilizon.Events do
|
|||||||
|> where(
|
|> where(
|
||||||
[e, et, a],
|
[e, et, a],
|
||||||
fragment(
|
fragment(
|
||||||
"(? = ?)::int * 5 + (? = ALL(?))::int * 2 + (? = ?)::int + (? is null or ST_DWithin(?::geography, ?::geography, ?::float))::int * 2 > ?",
|
"(? = ?)::int * 5 + (? = ALL(?))::int * 2 + (? = ?)::int + (?::geography is null or ST_DWithin(?::geography, ?::geography, ?::float))::int * 2 > ?",
|
||||||
e.language,
|
e.language,
|
||||||
^language,
|
^language,
|
||||||
et.tag_id,
|
et.tag_id,
|
||||||
^event_tags_ids,
|
^event_tags_ids,
|
||||||
e.category,
|
e.category,
|
||||||
^category,
|
^category,
|
||||||
a.geom,
|
^geom,
|
||||||
^geom,
|
^geom,
|
||||||
a.geom,
|
a.geom,
|
||||||
5000,
|
5000,
|
||||||
@ -1723,14 +1724,14 @@ defmodule Mobilizon.Events do
|
|||||||
|> order_by(
|
|> order_by(
|
||||||
[e, et, a],
|
[e, et, a],
|
||||||
fragment(
|
fragment(
|
||||||
"(? = ?)::int * 5 + (? = ALL(?))::int * 2 + (? = ?)::int + (? is null or ST_DWithin(?::geography, ?::geography, ?::float))::int * 2 DESC",
|
"(? = ?)::int * 5 + (? = ALL(?))::int * 2 + (? = ?)::int + (?::geography is null or ST_DWithin(?::geography, ?::geography, ?::float))::int * 2 DESC",
|
||||||
e.language,
|
e.language,
|
||||||
^language,
|
^language,
|
||||||
et.tag_id,
|
et.tag_id,
|
||||||
^event_tags_ids,
|
^event_tags_ids,
|
||||||
e.category,
|
e.category,
|
||||||
^category,
|
^category,
|
||||||
a.geom,
|
^geom,
|
||||||
^geom,
|
^geom,
|
||||||
a.geom,
|
a.geom,
|
||||||
5000
|
5000
|
||||||
|
Loading…
Reference in New Issue
Block a user