Skip to content

Commit

Permalink
Use unique_by when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
xjunior committed May 14, 2024
1 parent 9567195 commit d9b29c6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion audiences/app/models/audiences/external_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def self.wrap(resources)
attrs = resources.map do |data|
{ user_id: data["id"], data: data, created_at: Time.current, updated_at: Time.current }
end
upsert_all(attrs) # rubocop:disable Rails/SkipsModelValidations
unique_by = :user_id if connection.supports_insert_conflict_target?
upsert_all(attrs, unique_by: unique_by) # rubocop:disable Rails/SkipsModelValidations
where(user_id: attrs.pluck(:user_id))
end

Expand Down

0 comments on commit d9b29c6

Please sign in to comment.