Skip to content

Commit

Permalink
Forcibly recompute usage before syncing (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Aug 7, 2023
1 parent 3b5010d commit a4368e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/cron/lib/cron/task/usage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Cron.Task.Usage do
"""
use Cron
alias Core.Schema.Account
alias Core.Services.Payments
alias Core.Services.{Payments, Accounts}

def run() do
Account.usage_updated()
Expand All @@ -14,4 +14,10 @@ defmodule Cron.Task.Usage do
|> Stream.map(&Payments.sync_usage/1)
|> log()
end

defp sync_usage(%Account{} = account) do
with {:ok, account} <- Accounts.recompute_usage(account),
do: Payments.sync_usage(account)
end
defp sync_usage(_), do: :ok
end

0 comments on commit a4368e2

Please sign in to comment.