Skip to content

Commit

Permalink
Update the .attributes to .fields for integration
Browse files Browse the repository at this point in the history
  • Loading branch information
aprilrieger committed Nov 19, 2024
1 parent 5cce99c commit 4c2db80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/transactions/ams/steps/create_aapb_admin_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def save_aapb_admin_data(change_set)
find_or_create_admin_data(change_set)
set_admin_data_attributes(change_set.model.admin_data, change_set)
change_set.model.admin_data.save!
set_annotations_attributes(change_set.model.admin_data, change_set)
remove_admin_data_from_env_attributes(change_set)
delete_removed_annotations(change_set.model.admin_data, change_set)
set_annotations_attributes(change_set.model.admin_data, change_set)
remove_annotations_from_env_attributes(change_set)

!!change_set.model.admin_data
Expand All @@ -61,8 +61,8 @@ def set_admin_data_attributes(admin_data, change_set)

def delete_removed_annotations(admin_data, change_set)
return if admin_data.annotations.empty?
return if change_set.attributes["annotations"].nil?
ids_in_change_set = change_set.attributes["annotations"].select{ |ann| ann["id"].present? }.map{ |ann| ann["id"].to_i }
return if change_set.fields["annotations"].nil?
ids_in_change_set = change_set.fields["annotations"].select{ |ann| ann["id"].present? }.map{ |ann| ann["id"].to_i }
admin_data.annotations.each do |annotation|
annotation.destroy unless ids_in_change_set.include?(annotation.id)
end
Expand Down

0 comments on commit 4c2db80

Please sign in to comment.