Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
balanza committed Jul 23, 2024
1 parent 186f053 commit be5482f
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/trento/activity_log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule Trento.ActivityLog do

@spec clear_expired_logs() :: :ok | {:error, any()}
def clear_expired_logs do
with {:ok, retention_time} <- get_retention_time(),
with {:ok, %{retention_time: retention_time}} <- Trento.ActivityLog.get_settings(),
expiration_date <- calculate_expiration_date(retention_time) do
delete_logs_before(expiration_date)
:ok
Expand All @@ -69,13 +69,6 @@ defmodule Trento.ActivityLog do

defp log_error(result, _), do: result

defp get_retention_time do
case Trento.ActivityLog.get_settings() do
{:ok, settings} -> {:ok, settings.retention_time}
{:error, _} = error -> error
end
end

defp calculate_expiration_date(%RetentionTime{value: value, unit: :day}),
do: DateTime.add(DateTime.utc_now(), -value, :day)

Expand Down

0 comments on commit be5482f

Please sign in to comment.