Skip to content

Commit

Permalink
feat: improved jira issue job identification
Browse files Browse the repository at this point in the history
  • Loading branch information
celsoMartins committed Nov 13, 2024
1 parent 2e51ac2 commit 34b41f0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/controllers/webhook_integrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class WebhookIntegrationsController < ApplicationController
before_action :valid_jira_call?

def jira_webhook
Jira::ProcessJiraIssueJob.perform_later(Jira::JiraReader.instance.read_demand_key(jira_issue_attrs), jira_account, project, nil, nil, nil)
issue_id = Jira::JiraReader.instance.read_demand_key(jira_issue_attrs)

Jira::ProcessJiraIssueJob.perform_later(issue_id, jira_account, project, nil, nil, nil) unless already_in_the_queue?(issue_id)

head :ok
end
Expand All @@ -26,6 +28,11 @@ def jira_delete_card_webhook

private

def already_in_the_queue?(issue_id)
critical_queue = Sidekiq::Queue.new('critical')
critical_queue.map { |job| job['args'][0]['arguments'][0] }.any?(issue_id)
end

def valid_jira_call?
return head :ok if jira_issue_attrs.blank?
return head :ok if jira_account.blank?
Expand Down

0 comments on commit 34b41f0

Please sign in to comment.