summaryrefslogtreecommitdiff
path: root/app/models/sentry_issue.rb
blob: 1325bce6c434a6480f4414edb679c2f29e91ecc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class SentryIssue < ApplicationRecord
  belongs_to :issue

  validates :issue, uniqueness: true, presence: true
  validates :sentry_issue_identifier, presence: true

  after_create_commit :enqueue_sentry_sync_job

  def self.for_project_and_identifier(project, identifier)
    joins(:issue)
      .where(issues: { project_id: project.id })
      .find_by_sentry_issue_identifier(identifier)
  end

  def enqueue_sentry_sync_job
    ErrorTrackingIssueLinkWorker.perform_async(issue.id)
  end
end