Add cron job to clean old activities

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-02 14:34:52 +01:00
parent 3fade65c8e
commit 74e0e009d1
9 changed files with 192 additions and 7 deletions

View File

@@ -72,13 +72,14 @@ defmodule Mobilizon.Activities do
Repo.all(Activity)
end
@spec list_activities_for_group(
@spec list_group_activities_for_member(
integer() | String.t(),
integer() | String.t(),
Keyword.t(),
integer() | nil,
integer() | nil
) :: Page.t()
def list_activities_for_group(
def list_group_activities_for_member(
group_id,
actor_asking_id,
filters \\ [],
@@ -97,6 +98,26 @@ defmodule Mobilizon.Activities do
|> Page.build_page(page, limit)
end
@spec list_group_activities(
integer() | String.t(),
Keyword.t(),
integer() | nil,
integer() | nil
) :: Page.t()
def list_group_activities(
group_id,
filters \\ [],
page \\ nil,
limit \\ nil
) do
Activity
|> where([a], a.group_id == ^group_id)
|> filter_object_type(Keyword.get(filters, :type))
|> order_by(desc: :inserted_at)
|> preload([:author, :group])
|> Page.build_page(page, limit)
end
@doc """
Gets a single activity.