Updated

app/use_cases/accounts/apps/chatwoots/messages / delivery_job.rb

A
23 lines of codes
1 methods
26.0 complexity/method
22 churn
26.0 complexity
0 duplications
class Accounts::Apps::Chatwoots::Messages::DeliveryJob < ApplicationJob
  1. Accounts::Apps::Chatwoots::Messages::DeliveryJob has no descriptive comment
self.queue_adapter = :good_job def perform(event_id)
  1. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform has a flog score of 26
  2. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform has approx 8 statements
  3. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform doesn't depend on instance state (maybe move it to another class?)
event = Event.find(event_id) if event.should_delivery_event_scheduled? result = Accounts::Apps::Chatwoots::GetConversationAndSendMessage.call( event.app, event.contact.additional_attributes['chatwoot_id'], event.additional_attributes['chatwoot_inbox_id'],
  1. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform calls 'event.additional_attributes' 3 times Locations: 0 1 2
event ) if result.key?(:ok) event.additional_attributes['chatwoot_id'] = result[:ok]['id']
  1. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform calls 'event.additional_attributes' 3 times Locations: 0 1 2
  2. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform calls 'result[:ok]' 2 times Locations: 0 1
event.additional_attributes['chatwoot_conversation_id'] = result[:ok]['conversation_id']
  1. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform calls 'event.additional_attributes' 3 times Locations: 0 1 2
  2. Accounts::Apps::Chatwoots::Messages::DeliveryJob#perform calls 'result[:ok]' 2 times Locations: 0 1
event.done = true event.save! { ok: event } else { error: result[:error] } end end end end