Seems to have an issue with Diff
mikeni opened this issue · 4 comments
when diffing this
df = MapDiff.diff(
%{"short_name" => nil, "lifetime_pacing" => false,
"allow_unverified_ecp" => false,
"code" => "bob-3015b868-4b29-11e7-9eca-6c40088b4566",
"cpm_bid_type" => "base", "lifetime_budget_imps" => 58500,
"learn_override_type" => nil, "projected_learn_events" => nil,
"timezone" => "Etc/UTC", "labels" => nil,
"start_date" => "2015-05-10 04:15:02", "optimization_version" => "v7",
"valuation" => nil, "daily_budget_imps" => 58500,
"roadblock_type" => "no_roadblock", "id" => 16998110,
"advertiser_id" => 1821428, "roadblock_creatives" => false,
"supply_type" => "web", "base_bid" => 3.02, "total_days" => 3,
"optimization_lookback" => nil, "bid_modifier_model" => nil,
"lifetime_budget" => nil, "campaign_modifiers" => nil, "max_learn_bid" => nil,
"remaining_days" => nil, "defer_to_li_prediction" => false, "max_bid" => nil,
"profile_id" => 84609840, "pixels" => nil, "pixel_id" => nil,
"bid_multiplier" => 1, "daily_budget" => nil, "enable_pacing" => true,
"supply_type_action" => "include", "comments" => nil,
"creatives" => [%{"audit_status" => "pending", "code" => nil,
"format" => "url-js", "height" => 250, "id" => 69777858,
"is_expired" => false, "is_prohibited" => false,
"is_self_audited" => false, "name" => "my 300x250 creative",
"pop_window_maximize" => nil, "state" => "active", "weight" => nil,
"width" => 300},
%{"audit_status" => "pending", "code" => nil, "format" => "url-js",
"height" => 250, "id" => 69777859, "is_expired" => false,
"is_prohibited" => false, "is_self_audited" => false,
"name" => "my 300x250 creative 2", "pop_window_maximize" => nil,
"state" => "active", "weight" => nil, "width" => 300}],
"impression_limit" => 40000, "creative_id" => 69777858, "state" => "active",
"name" => "my boost reason", "learn_threshold" => 3,
"base_cpm_bid_value" => nil, "creative_distribution_type" => nil,
"priority" => 5, "broker_fees" => nil, "end_date" => "2015-05-12 06:45:12",
"cadence_type" => "advertiser", "click_url" => nil,
"allow_safety_pacing" => true, "member_id" => 3102, "bid_model" => nil,
"require_cookie_for_tracking" => true, "lifetime_pacing_span" => nil,
"min_bid" => nil, "inventory_type" => "real_time",
"cadence_modifier_enabled" => false, "bid_margin" => 0,
"ecp_learn_divisor" => nil, "cpc_payout" => nil, "campaign_type" => "default",
"cpc_goal" => nil, "allocation_pct" => nil, "lifetime_pacing_pct" => 100,
"line_item_id" => 4164352},
%{"short_name" => nil, "lifetime_pacing" => false,
"allow_unverified_ecp" => false,
"code" => "bob-44785afe-4b29-11e7-9a09-6c40088b4566",
"cpm_bid_type" => "base", "lifetime_budget_imps" => 18000,
"learn_override_type" => nil, "projected_learn_events" => nil,
"timezone" => "Etc/UTC", "labels" => nil,
"start_date" => "2015-05-10 04:15:02", "optimization_version" => "v7",
"valuation" => nil, "daily_budget_imps" => 18000,
"roadblock_type" => "no_roadblock", "id" => 16998110,
"advertiser_id" => 1821428, "roadblock_creatives" => false,
"supply_type" => "web", "base_bid" => 3.02, "total_days" => 4,
"optimization_lookback" => nil, "bid_modifier_model" => nil,
"lifetime_budget" => nil, "campaign_modifiers" => nil, "max_learn_bid" => nil,
"remaining_days" => nil, "defer_to_li_prediction" => false, "max_bid" => nil,
"profile_id" => 84609840, "pixels" => nil, "pixel_id" => nil,
"bid_multiplier" => 1, "daily_budget" => nil, "enable_pacing" => true,
"supply_type_action" => "include", "comments" => nil,
"creatives" => [%{"audit_status" => "pending", "code" => nil,
"format" => "url-js", "height" => 250, "id" => 69777858,
"is_expired" => false, "is_prohibited" => false,
"is_self_audited" => false, "name" => "my 300x250 creative",
"pop_window_maximize" => nil, "state" => "active", "weight" => nil,
"width" => 300},
%{"audit_status" => "pending", "code" => nil, "format" => "url-js",
"height" => 250, "id" => 69777859, "is_expired" => false,
"is_prohibited" => false, "is_self_audited" => false,
"name" => "my 300x250 creative 2", "pop_window_maximize" => nil,
"state" => "active", "weight" => nil, "width" => 300}],
"impression_limit" => 40000, "creative_id" => 69777858, "state" => "inactive",
"name" => "my boost another reason", "learn_threshold" => 3,
"base_cpm_bid_value" => nil, "creative_distribution_type" => nil,
"priority" => 5, "broker_fees" => nil, "end_date" => "2015-05-13 06:45:12",
"cadence_type" => "advertiser", "click_url" => nil,
"allow_safety_pacing" => true, "member_id" => 3102, "bid_model" => nil,
"require_cookie_for_tracking" => true, "lifetime_pacing_span" => nil,
"min_bid" => nil, "inventory_type" => "real_time",
"cadence_modifier_enabled" => false, "bid_margin" => 0,
"ecp_learn_divisor" => nil, "cpc_payout" => nil, "campaign_type" => "default",
"cpc_goal" => nil, "allocation_pct" => nil, "lifetime_pacing_pct" => 100,
"line_item_id" => 4164352}
)
it is returning
%{added: %{"short_name" => nil, "lifetime_pacing" => false,
"allow_unverified_ecp" => false,
"code" => "bob-44785afe-4b29-11e7-9a09-6c40088b4566",
"cpm_bid_type" => "base", "lifetime_budget_imps" => 18000,
"learn_override_type" => nil, "projected_learn_events" => nil,
"timezone" => "Etc/UTC", "labels" => nil,
"start_date" => "2015-05-10 04:15:02", "optimization_version" => "v7",
"valuation" => nil, "daily_budget_imps" => 18000,
"roadblock_type" => "no_roadblock", "id" => 16998110,
"advertiser_id" => 1821428, "roadblock_creatives" => false,
"supply_type" => "web", "base_bid" => 3.02, "total_days" => 4,
"optimization_lookback" => nil, "bid_modifier_model" => nil,
"lifetime_budget" => nil, "campaign_modifiers" => nil,
"max_learn_bid" => nil, "remaining_days" => nil,
"defer_to_li_prediction" => false, "max_bid" => nil,
"profile_id" => 84609840, "pixels" => nil, "pixel_id" => nil,
"bid_multiplier" => 1, "daily_budget" => nil, "enable_pacing" => true,
"supply_type_action" => "include", "comments" => nil,
"creatives" => [%{"audit_status" => "pending", "code" => nil,
"format" => "url-js", "height" => 250, "id" => 69777858,
"is_expired" => false, "is_prohibited" => false,
"is_self_audited" => false, "name" => "my 300x250 creative",
"pop_window_maximize" => nil, "state" => "active", "weight" => nil,
"width" => 300},
%{"audit_status" => "pending", "code" => nil, "format" => "url-js",
"height" => 250, "id" => 69777859, "is_expired" => false,
"is_prohibited" => false, "is_self_audited" => false,
"name" => "my 300x250 creative 2", "pop_window_maximize" => nil,
"state" => "active", "weight" => nil, "width" => 300}],
"impression_limit" => 40000, "creative_id" => 69777858,
"state" => "inactive", "name" => "my boost another reason",
"learn_threshold" => 3, "base_cpm_bid_value" => nil,
"creative_distribution_type" => nil, "priority" => 5, "broker_fees" => nil,
"end_date" => "2015-05-13 06:45:12", "cadence_type" => "advertiser",
"click_url" => nil, "allow_safety_pacing" => true, "member_id" => 3102,
"bid_model" => nil, "require_cookie_for_tracking" => true,
"lifetime_pacing_span" => nil, "min_bid" => nil,
"inventory_type" => "real_time", "cadence_modifier_enabled" => false,
"bid_margin" => 0, "ecp_learn_divisor" => nil, "cpc_payout" => nil,
"campaign_type" => "default", "cpc_goal" => nil, "allocation_pct" => nil,
"lifetime_pacing_pct" => 100, "line_item_id" => 4164352},
changed: :map_change,
removed: %{"short_name" => nil, "lifetime_pacing" => false,
"allow_unverified_ecp" => false,
"code" => "bob-3015b868-4b29-11e7-9eca-6c40088b4566",
"cpm_bid_type" => "base", "lifetime_budget_imps" => 58500,
"learn_override_type" => nil, "projected_learn_events" => nil,
"timezone" => "Etc/UTC", "labels" => nil,
"start_date" => "2015-05-10 04:15:02", "optimization_version" => "v7",
"valuation" => nil, "daily_budget_imps" => 58500,
"roadblock_type" => "no_roadblock", "id" => 16998110,
"advertiser_id" => 1821428, "roadblock_creatives" => false,
"supply_type" => "web", "base_bid" => 3.02, "total_days" => 3,
"optimization_lookback" => nil, "bid_modifier_model" => nil,
"lifetime_budget" => nil, "campaign_modifiers" => nil,
"max_learn_bid" => nil, "remaining_days" => nil,
"defer_to_li_prediction" => false, "max_bid" => nil,
"profile_id" => 84609840, "pixels" => nil, "pixel_id" => nil,
"bid_multiplier" => 1, "daily_budget" => nil, "enable_pacing" => true,
"supply_type_action" => "include", "comments" => nil,
"creatives" => [%{"audit_status" => "pending", "code" => nil,
"format" => "url-js", "height" => 250, "id" => 69777858,
"is_expired" => false, "is_prohibited" => false,
"is_self_audited" => false, "name" => "my 300x250 creative",
"pop_window_maximize" => nil, "state" => "active", "weight" => nil,
"width" => 300},
%{"audit_status" => "pending", "code" => nil, "format" => "url-js",
"height" => 250, "id" => 69777859, "is_expired" => false,
"is_prohibited" => false, "is_self_audited" => false,
"name" => "my 300x250 creative 2", "pop_window_maximize" => nil,
"state" => "active", "weight" => nil, "width" => 300}],
"impression_limit" => 40000, "creative_id" => 69777858, "state" => "active",
"name" => "my boost reason", "learn_threshold" => 3,
"base_cpm_bid_value" => nil, "creative_distribution_type" => nil,
"priority" => 5, "broker_fees" => nil, "end_date" => "2015-05-12 06:45:12",
"cadence_type" => "advertiser", "click_url" => nil,
"allow_safety_pacing" => true, "member_id" => 3102, "bid_model" => nil,
"require_cookie_for_tracking" => true, "lifetime_pacing_span" => nil,
"min_bid" => nil, "inventory_type" => "real_time",
"cadence_modifier_enabled" => false, "bid_margin" => 0,
"ecp_learn_divisor" => nil, "cpc_payout" => nil,
"campaign_type" => "default", "cpc_goal" => nil, "allocation_pct" => nil,
"lifetime_pacing_pct" => 100, "line_item_id" => 4164352},
value: %{"short_name" => %{changed: :equal, value: nil},
"lifetime_pacing" => %{changed: :equal, value: false},
"allow_unverified_ecp" => %{changed: :equal, value: false},
"code" => %{added: "bob-44785afe-4b29-11e7-9a09-6c40088b4566",
changed: :primitive_change,
removed: "bob-3015b868-4b29-11e7-9eca-6c40088b4566"},
"cpm_bid_type" => %{changed: :equal, value: "base"},
"lifetime_budget_imps" => %{added: 18000, changed: :primitive_change,
removed: 58500}, "learn_override_type" => %{changed: :equal, value: nil},
"projected_learn_events" => %{changed: :equal, value: nil},
"timezone" => %{changed: :equal, value: "Etc/UTC"},
"labels" => %{changed: :equal, value: nil},
"start_date" => %{changed: :equal, value: "2015-05-10 04:15:02"},
"optimization_version" => %{changed: :equal, value: "v7"},
"valuation" => %{changed: :equal, value: nil},
"daily_budget_imps" => %{added: 18000, changed: :primitive_change,
removed: 58500},
"roadblock_type" => %{changed: :equal, value: "no_roadblock"},
"id" => %{changed: :equal, value: 16998110},
"advertiser_id" => %{changed: :equal, value: 1821428},
"roadblock_creatives" => %{changed: :equal, value: false},
"supply_type" => %{changed: :equal, value: "web"},
"base_bid" => %{changed: :equal, value: 3.02},
"total_days" => %{added: 4, changed: :primitive_change, removed: 3},
"optimization_lookback" => %{changed: :equal, value: nil},
"bid_modifier_model" => %{changed: :equal, value: nil},
"lifetime_budget" => %{changed: :equal, value: nil},
"campaign_modifiers" => %{changed: :equal, value: nil},
"max_learn_bid" => %{changed: :equal, value: nil},
"remaining_days" => %{changed: :equal, value: nil},
"defer_to_li_prediction" => %{changed: :equal, value: false},
"max_bid" => %{changed: :equal, value: nil},
"profile_id" => %{changed: :equal, value: 84609840},
"pixels" => %{changed: :equal, value: nil},
"pixel_id" => %{changed: :equal, value: nil},
"bid_multiplier" => %{changed: :equal, value: 1},
"daily_budget" => %{changed: :equal, value: nil},
"enable_pacing" => %{changed: :equal, value: true},
"supply_type_action" => %{changed: :equal, value: "include"},
"comments" => %{changed: :equal, value: nil},
"creatives" => %{changed: :equal,
value: [%{"audit_status" => "pending", "code" => nil,
"format" => "url-js", "height" => 250, "id" => 69777858,
"is_expired" => false, "is_prohibited" => false,
"is_self_audited" => false, "name" => "my 300x250 creative",
"pop_window_maximize" => nil, "state" => "active", "weight" => nil,
"width" => 300},
%{"audit_status" => "pending", "code" => nil, "format" => "url-js",
"height" => 250, "id" => 69777859, "is_expired" => false,
"is_prohibited" => false, "is_self_audited" => false,
"name" => "my 300x250 creative 2", "pop_window_maximize" => nil,
"state" => "active", "weight" => nil, "width" => 300}]},
"impression_limit" => %{changed: :equal, value: 40000},
"creative_id" => %{changed: :equal, value: 69777858},
"state" => %{added: "inactive", changed: :primitive_change,
removed: "active"},
"name" => %{added: "my boost another reason", changed: :primitive_change,
removed: "my boost reason"},
"learn_threshold" => %{changed: :equal, value: 3},
"base_cpm_bid_value" => %{changed: :equal, value: nil},
"creative_distribution_type" => %{changed: :equal, value: nil},
"priority" => %{changed: :equal, value: 5},
"broker_fees" => %{changed: :equal, value: nil},
"end_date" => %{added: "2015-05-13 06:45:12", changed: :primitive_change,
removed: "2015-05-12 06:45:12"},
"cadence_type" => %{changed: :equal, value: "advertiser"},
"click_url" => %{changed: :equal, value: nil},
"allow_safety_pacing" => %{changed: :equal, value: true},
"member_id" => %{changed: :equal, value: 3102},
"bid_model" => %{changed: :equal, value: nil},
"require_cookie_for_tracking" => %{changed: :equal, value: true},
"lifetime_pacing_span" => %{changed: :equal, value: nil},
"min_bid" => %{changed: :equal, value: nil},
"inventory_type" => %{changed: :equal, value: "real_time"},
"cadence_modifier_enabled" => %{changed: :equal, value: false},
"bid_margin" => %{changed: :equal, value: 0},
"ecp_learn_divisor" => %{changed: :equal, value: nil},
"cpc_payout" => %{changed: :equal, value: nil},
"campaign_type" => %{changed: :equal, value: "default"},
"cpc_goal" => %{changed: :equal, value: nil},
"allocation_pct" => %{changed: :equal, value: nil},
"lifetime_pacing_pct" => %{changed: :equal, value: 100},
"line_item_id" => %{changed: :equal, value: 4164352}}}
Thank you for your issue report!
As far as I am able to tell, the output is correct: There are some subfields of the main map that are changed, which means that :changed
is set to :map_change
and :added
and :removed
are filled in with the new and old map, respectively. Finally, :value
contains the information of the nested fields of the change.
Please elaborate: What is the issue you are facing?
Hmm I tested this basic one
MapDiff.diff(%{a: 1}, %{})
I'm getting
%{added: %{}, changed: :map_change, removed: %{a: 1}, value: %{a: %{changed: :removed, value: 1}}}
which is different than your readme
ok it seems to always diff the root map itself,
it always "added" the 2nd parameter map and removed the 1st parameter map
Yes, you are right! Turns out I the README has not been updated during the last code revision.
Indeed, the change in 1.3.0
, which the examples in the README do not yet reflect, is that at each level of the result, the :added
and :removed
keys contain maps of all values that were either added, changed or removed. (So they do not contain fields that are still equal).
Thank you very much for your report! I will update the README to reflect the changes in 1.3.0
. 😅