Handle events with no physical location
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -1691,11 +1691,12 @@ defmodule Mobilizon.Events do
|
||||
def related_events(%Event{
|
||||
id: event_id,
|
||||
tags: tags,
|
||||
physical_address: %Address{geom: geom},
|
||||
physical_address: physical_address,
|
||||
category: category,
|
||||
language: language
|
||||
}) do
|
||||
event_tags_ids = Enum.map(tags, & &1.id)
|
||||
geom = if is_nil(physical_address), do: nil, else: physical_address.geom
|
||||
|
||||
Event
|
||||
|> distinct([e], e.id)
|
||||
@@ -1704,14 +1705,14 @@ defmodule Mobilizon.Events do
|
||||
|> where(
|
||||
[e, et, a],
|
||||
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,
|
||||
^language,
|
||||
et.tag_id,
|
||||
^event_tags_ids,
|
||||
e.category,
|
||||
^category,
|
||||
a.geom,
|
||||
^geom,
|
||||
^geom,
|
||||
a.geom,
|
||||
5000,
|
||||
@@ -1723,14 +1724,14 @@ defmodule Mobilizon.Events do
|
||||
|> order_by(
|
||||
[e, et, a],
|
||||
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,
|
||||
^language,
|
||||
et.tag_id,
|
||||
^event_tags_ids,
|
||||
e.category,
|
||||
^category,
|
||||
a.geom,
|
||||
^geom,
|
||||
^geom,
|
||||
a.geom,
|
||||
5000
|
||||
|
||||
Reference in New Issue
Block a user