Class: SentryIssue

Inherits:
ApplicationRecord show all
Includes:
Importable
Defined in:
app/models/sentry_issue.rb

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

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

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.for_project_and_identifier(project, identifier) ⇒ Object



15
16
17
18
19
20
# File 'app/models/sentry_issue.rb', line 15

def self.for_project_and_identifier(project, identifier)
  joins(:issue)
    .where(issues: { project_id: project.id })
    .where(sentry_issue_identifier: identifier)
    .order('issues.created_at').last
end

Instance Method Details

#enqueue_sentry_sync_jobObject



29
30
31
# File 'app/models/sentry_issue.rb', line 29

def enqueue_sentry_sync_job
  ErrorTrackingIssueLinkWorker.perform_async(issue.id)
end

#ensure_sentry_issue_identifier_is_unique_per_projectObject



22
23
24
25
26
27
# File 'app/models/sentry_issue.rb', line 22

def ensure_sentry_issue_identifier_is_unique_per_project
  if issue && self.class.for_project_and_identifier(issue.project, sentry_issue_identifier).present?
    # Custom message because field is hidden
    errors.add(:_, _('is already associated to a GitLab Issue. New issue will not be associated.'))
  end
end