Skip to content

Commit

Permalink
Merge pull request ZennerIoT#73 from revati/version_changeset
Browse files Browse the repository at this point in the history
call version changeset
  • Loading branch information
narrowtux authored Jul 14, 2021
2 parents 4433688 + df5d2f9 commit e5d6ab4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/tracking/tracking.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,22 @@ defmodule ExAudit.Tracking do

def insert_versions(module, changes, opts) do
now = DateTime.utc_now()
empty_version_schema = struct(version_schema(), %{})

custom_fields =
Keyword.get(opts, :ex_audit_custom, [])
|> Enum.into(%{})

changes =
Enum.map(changes, fn change ->
change = Map.put(change, :recorded_at, now)
Map.merge(change, custom_fields)
change =
change
|> Map.put(:recorded_at, now)
|> Map.merge(custom_fields)

version_schema()
|> apply(:changeset, [empty_version_schema, change])
|> Map.get(:changes)
end)

case changes do
Expand Down

0 comments on commit e5d6ab4

Please sign in to comment.