Skip to content

Commit

Permalink
improvement: use read_metadata when manually scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Aug 24, 2023
1 parent b628984 commit 706fcdf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/ash_oban.ex
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,16 @@ defmodule AshOban do

primary_key = Ash.Resource.Info.primary_key(resource)

%{primary_key: Map.take(record, primary_key)}
metadata =
case trigger do
%{read_metadata: read_metadata} when is_function(read_metadata) ->
read_metadata.(record)

_ ->
%{}
end

%{primary_key: Map.take(record, primary_key), metadata: metadata}
|> trigger.worker.new()
|> Oban.insert!()
end
Expand Down

0 comments on commit 706fcdf

Please sign in to comment.