From 618eb5b8695b58587516830475231240b6cc2c77 Mon Sep 17 00:00:00 2001 From: Chris Nelson Date: Wed, 4 Dec 2024 17:02:17 -0500 Subject: [PATCH] don't need to double check if schema is tracked, we already know --- lib/tracking/tracking.ex | 46 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/tracking/tracking.ex b/lib/tracking/tracking.ex index 801224f..794640e 100644 --- a/lib/tracking/tracking.ex +++ b/lib/tracking/tracking.ex @@ -23,31 +23,27 @@ defmodule ExAudit.Tracking do def compare_versions(action, old, new) do schema = Map.get(old, :__struct__, Map.get(new, :__struct__)) - if schema in tracked_schemas() do - assocs = schema.__schema__(:associations) - - patch = - ExAudit.Diff.diff( - ExAudit.Tracker.map_struct(old) |> Map.drop(assocs), - ExAudit.Tracker.map_struct(new) |> Map.drop(assocs) - ) - - case patch do - :not_changed -> - [] - - patch -> - params = %{ - entity_id: Map.get(old, :id) || Map.get(new, :id), - entity_schema: schema, - patch: patch, - action: action - } - - [params] - end - else - [] + assocs = schema.__schema__(:associations) + + patch = + ExAudit.Diff.diff( + ExAudit.Tracker.map_struct(old) |> Map.drop(assocs), + ExAudit.Tracker.map_struct(new) |> Map.drop(assocs) + ) + + case patch do + :not_changed -> + [] + + patch -> + params = %{ + entity_id: Map.get(old, :id) || Map.get(new, :id), + entity_schema: schema, + patch: patch, + action: action + } + + [params] end end