Skip to content

Commit

Permalink
fix automation update
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinSchneider committed May 16, 2024
1 parent 05358ef commit deb67f8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backend/app/models/concerns/indexable_json_key_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ def index_key_values!(jsonb_column, *keys)
end

after_update do
return if !self.saved_change_to_attribute?(jsonb_column)
keys.each do |key|
config_key_changed = ((self.saved_changes[jsonb_column] || [])[0] || {})[key] != ((self.saved_changes[jsonb_column] || [])[1] || {})[key]
next if !config_key_changed
self.indexed_jsonb_keys.where(column: jsonb_column, key: key).update_all(value: self.send(jsonb_column).try(:[], key))
if self.saved_change_to_attribute?(jsonb_column)
keys.each do |key|
config_key_changed = ((self.saved_changes[jsonb_column] || [])[0] || {})[key] != ((self.saved_changes[jsonb_column] || [])[1] || {})[key]
next if !config_key_changed
self.indexed_jsonb_keys.where(column: jsonb_column, key: key).update_all(value: self.send(jsonb_column).try(:[], key))
end
end
end

Expand Down

0 comments on commit deb67f8

Please sign in to comment.