Fix ICS feed missing events: order by "begins_on" DESC so that the latest events are always included

potsda.mn/mobilizon#37
This commit is contained in:
summersamara 2023-12-20 02:09:46 +01:00 committed by Thomas Citharel
parent 2fba6379f1
commit 31411bfc03
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 5 additions and 3 deletions

View file

@ -387,13 +387,15 @@ defmodule Mobilizon.Events do
|> Repo.stream()
end
@spec list_public_local_events(integer | nil, integer | nil) :: Page.t(Event.t())
def list_public_local_events(page \\ nil, limit \\ nil) do
@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, sort \\ nil, direction \\ nil) do
Event
|> filter_public_visibility()
|> filter_draft()
|> filter_local()
|> preload_for_event()
|> event_order_by(sort, direction)
|> Page.build_page(page, limit)
end

View file

@ -96,7 +96,7 @@ defmodule Mobilizon.Service.Export.Common do
@spec fetch_instance_public_content(integer()) :: {:ok, list(Event.t()), list(Post.t())}
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)
{:ok, events, posts}
end