Class: SentryIssue

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.for_project_and_identifier(project, identifier) ⇒ Object


12
13
14
15
16
17
# File 'app/models/sentry_issue.rb', line 12

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


26
27
28
# File 'app/models/sentry_issue.rb', line 26

def enqueue_sentry_sync_job
  ErrorTrackingIssueLinkWorker.perform_async(issue.id)
end

#ensure_sentry_issue_identifier_is_unique_per_projectObject


19
20
21
22
23
24
# File 'app/models/sentry_issue.rb', line 19

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