mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
cronjob to clean mod logs
This commit is contained in:
parent
ee1cca8fe4
commit
c776a29094
3 changed files with 12 additions and 0 deletions
|
@ -9,6 +9,7 @@ background() {
|
|||
mix run -e 'Philomena.Release.update_channels()'
|
||||
mix run -e 'Philomena.Release.verify_artist_links()'
|
||||
mix run -e 'Philomena.Release.update_stats()'
|
||||
mix run -e 'Philomena.Release.clean_moderation_logs()'
|
||||
|
||||
sleep 300
|
||||
done
|
||||
|
|
|
@ -74,4 +74,10 @@ defmodule Philomena.ModerationLogs do
|
|||
def delete_moderation_log(%ModerationLog{} = moderation_log) do
|
||||
Repo.delete(moderation_log)
|
||||
end
|
||||
|
||||
def cleanup! do
|
||||
ModerationLog
|
||||
|> where([ml], ml.created_at < ago(2, "week"))
|
||||
|> Repo.delete_all()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,11 @@ defmodule Philomena.Release do
|
|||
PhilomenaWeb.StatsUpdater.update_stats!()
|
||||
end
|
||||
|
||||
def clean_moderation_logs do
|
||||
start_app()
|
||||
Philomena.ModerationLogs.cleanup!()
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue