Supply sort and direction as arguments to list_public_local_events instead of hardcoding
#37
This commit is contained in:
parent
5fb5897c34
commit
1d430f5707
|
@ -387,15 +387,15 @@ defmodule Mobilizon.Events do
|
||||||
|> Repo.stream()
|
|> Repo.stream()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec list_public_local_events(integer | nil, integer | nil) :: Page.t(Event.t())
|
@spec list_public_local_events(integer | nil, integer | nil, atom | nil, atom | nil) :: Page.t(Event.t())
|
||||||
def list_public_local_events(page \\ nil, limit \\ nil) do
|
def list_public_local_events(page \\ nil, limit \\ nil, sort \\ nil, direction \\ nil) do
|
||||||
Event
|
Event
|
||||||
|> filter_public_visibility()
|
|> filter_public_visibility()
|
||||||
|> filter_draft()
|
|> filter_draft()
|
||||||
|> filter_local()
|
|> filter_local()
|
||||||
|> preload_for_event()
|
|> preload_for_event()
|
||||||
|> order_by(desc: :begins_on)
|
|> event_order_by(sort, direction)
|
||||||
|> Page.build_page(page, limit, :begins_on)
|
|> Page.build_page(page, limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -96,7 +96,7 @@ defmodule Mobilizon.Service.Export.Common do
|
||||||
|
|
||||||
@spec fetch_instance_public_content(integer()) :: {:ok, list(Event.t()), list(Post.t())}
|
@spec fetch_instance_public_content(integer()) :: {:ok, list(Event.t()), list(Post.t())}
|
||||||
def fetch_instance_public_content(limit) do
|
def fetch_instance_public_content(limit) do
|
||||||
%Page{elements: events} = Events.list_public_local_events(1, limit)
|
%Page{elements: events} = Events.list_public_local_events(1, limit, :begins_on, :desc)
|
||||||
%Page{elements: posts} = Posts.list_public_local_posts(1, limit)
|
%Page{elements: posts} = Posts.list_public_local_posts(1, limit)
|
||||||
{:ok, events, posts}
|
{:ok, events, posts}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue