diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /app/models/customer_relations/contact.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'app/models/customer_relations/contact.rb')
-rw-r--r-- | app/models/customer_relations/contact.rb | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/app/models/customer_relations/contact.rb b/app/models/customer_relations/contact.rb index f6455da890b..16c741d340f 100644 --- a/app/models/customer_relations/contact.rb +++ b/app/models/customer_relations/contact.rb @@ -79,22 +79,23 @@ class CustomerRelations::Contact < ApplicationRecord end def self.sort_by_name - order(Gitlab::Pagination::Keyset::Order.build([ - Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( - attribute_name: 'last_name', - order_expression: arel_table[:last_name].asc, - distinct: false - ), - Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( - attribute_name: 'first_name', - order_expression: arel_table[:first_name].asc, - distinct: false - ), - Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( - attribute_name: 'id', - order_expression: arel_table[:id].asc - ) - ])) + order(Gitlab::Pagination::Keyset::Order.build( + [ + Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'last_name', + order_expression: arel_table[:last_name].asc, + distinct: false + ), + Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'first_name', + order_expression: arel_table[:first_name].asc, + distinct: false + ), + Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'id', + order_expression: arel_table[:id].asc + ) + ])) end def self.find_ids_by_emails(group, emails) @@ -117,22 +118,14 @@ class CustomerRelations::Contact < ApplicationRecord JOIN #{table_name} AS new_contacts ON new_contacts.group_id = :old_group_id AND LOWER(new_contacts.email) = LOWER(existing_contacts.email) WHERE existing_contacts.group_id = :new_group_id AND contact_id = existing_contacts.id SQL - connection.execute(sanitize_sql([ - update_query, - old_group_id: group.root_ancestor.id, - new_group_id: group.id - ])) + connection.execute(sanitize_sql([update_query, old_group_id: group.root_ancestor.id, new_group_id: group.id])) dupes_query = <<~SQL DELETE FROM #{table_name} AS existing_contacts USING #{table_name} AS new_contacts WHERE existing_contacts.group_id = :new_group_id AND new_contacts.group_id = :old_group_id AND LOWER(new_contacts.email) = LOWER(existing_contacts.email) SQL - connection.execute(sanitize_sql([ - dupes_query, - old_group_id: group.root_ancestor.id, - new_group_id: group.id - ])) + connection.execute(sanitize_sql([dupes_query, old_group_id: group.root_ancestor.id, new_group_id: group.id])) where(group: group).update_all(group_id: group.root_ancestor.id) end |