Add all proper filters for related events
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
f0c8fa2525
commit
1601153062
@ -1688,6 +1688,7 @@ defmodule Mobilizon.Events do
|
|||||||
|
|
||||||
@threshold_related_value 7
|
@threshold_related_value 7
|
||||||
|
|
||||||
|
@spec related_events(Event.t()) :: list(Event.t())
|
||||||
def related_events(%Event{
|
def related_events(%Event{
|
||||||
id: event_id,
|
id: event_id,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
@ -1702,6 +1703,10 @@ defmodule Mobilizon.Events do
|
|||||||
|> distinct([e], e.id)
|
|> distinct([e], e.id)
|
||||||
|> join(:left, [e], et in "events_tags", on: e.id == et.event_id)
|
|> join(:left, [e], et in "events_tags", on: e.id == et.event_id)
|
||||||
|> join(:left, [e], a in Address, on: e.physical_address_id == a.id)
|
|> join(:left, [e], a in Address, on: e.physical_address_id == a.id)
|
||||||
|
|> events_for_begins_on(%{})
|
||||||
|
|> filter_draft()
|
||||||
|
|> filter_local_or_from_followed_instances_events()
|
||||||
|
|> filter_public_visibility()
|
||||||
|> where(
|
|> where(
|
||||||
[e, et, a],
|
[e, et, a],
|
||||||
fragment(
|
fragment(
|
||||||
@ -1719,7 +1724,6 @@ defmodule Mobilizon.Events do
|
|||||||
@threshold_related_value
|
@threshold_related_value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# |> where([e], e.begins_on > ^DateTime.utc_now())
|
|
||||||
|> where([e], e.id != ^event_id)
|
|> where([e], e.id != ^event_id)
|
||||||
|> order_by(
|
|> order_by(
|
||||||
[e, et, a],
|
[e, et, a],
|
||||||
|
Loading…
Reference in New Issue
Block a user