Class: CustomerRelations::IssueContact
Constant Summary
collapse
- BATCH_DELETE_SIZE =
1_000
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary
collapse
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Class Method Details
.delete_for_group(group) ⇒ Object
28
29
30
31
32
33
|
# File 'app/models/customer_relations/issue_contact.rb', line 28
def self.delete_for_group(group)
loop do
deleted_records = joins(issue: :project).where(projects: { namespace: group.self_and_descendants }).limit(BATCH_DELETE_SIZE).delete_all
break if deleted_records == 0
end
end
|
.delete_for_project(project_id) ⇒ Object
21
22
23
24
25
26
|
# File 'app/models/customer_relations/issue_contact.rb', line 21
def self.delete_for_project(project_id)
loop do
deleted_records = joins(:issue).where(issues: { project_id: project_id }).limit(BATCH_DELETE_SIZE).delete_all
break if deleted_records == 0
end
end
|
13
14
15
16
17
18
19
|
# File 'app/models/customer_relations/issue_contact.rb', line 13
def self.find_contact_ids_by_emails(issue_id, emails)
raise ArgumentError, "Cannot lookup more than #{MAX_PLUCK} emails" if emails.length > MAX_PLUCK
joins(:contact)
.where(issue_id: issue_id, customer_relations_contacts: { email: emails })
.pluck(:contact_id)
end
|