Skip to content

Commit

Permalink
refactor(ex/skate/detours): pattern match in send_notification
Browse files Browse the repository at this point in the history
  • Loading branch information
firestack committed Nov 4, 2024
1 parent f0b86b8 commit fe09697
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/skate/detours/detours.ex
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,7 @@ defmodule Skate.Detours.Detours do
on_conflict: {:replace, [:state, :updated_at]}
)

case detour_db_result do
{:ok, %Detour{} = new_record} ->
send_notification(new_record, previous_record, author_id)

_ ->
nil
end
send_notification(new_record, previous_record, author_id)

detour_db_result
end
Expand Down Expand Up @@ -249,6 +243,19 @@ defmodule Skate.Detours.Detours do
next: detour_type() | nil,
previous: detour_type() | nil
}) :: :ok | nil

defp send_notification(
{:ok, %Detour{} = new_record},
%Detour{} = previous_record,
user_id
) do
send_notification(
new_record,
previous_record,
user_id
)
end

defp send_notification(
%Detour{} = new_record,
%Detour{} = previous_record,
Expand Down

0 comments on commit fe09697

Please sign in to comment.