Updated

app/use_cases/pwa / send_notifications_worker.rb

A
22 lines of codes
1 methods
37.4 complexity/method
9 churn
37.36 complexity
0 duplications
class Pwa::SendNotificationsWorker < ApplicationJob
  1. Pwa::SendNotificationsWorker has no descriptive comment
self.queue_adapter = :good_job def perform(event_id)
  1. Pwa::SendNotificationsWorker#perform has a flog score of 37
  2. Pwa::SendNotificationsWorker#perform doesn't depend on instance state (maybe move it to another class?)
event = Event.find(event_id) if event.present? && event.should_delivery_event_scheduled? WebpushSubscription.find_each do |subscription| if subscription.user.webpush_notify_on_event_expired subscription.send_notification( { title: "#{Event.human_enum_name(:kind, event.kind)} #{event.title}",
  1. Pwa::SendNotificationsWorker#perform calls 'Event.human_enum_name(:kind, event.kind)' 2 times Locations: 0 1
  2. Pwa::SendNotificationsWorker#perform calls 'event.kind' 2 times Locations: 0 1
  3. Pwa::SendNotificationsWorker#perform calls 'event.title' 2 times Locations: 0 1
body: I18n.t('use_cases.pwa.send_notifications_worker.body', event_kind: Event.human_enum_name(:kind, event.kind), event_title: event.title, deal_name: event.deal.name),
  1. Pwa::SendNotificationsWorker#perform calls 'Event.human_enum_name(:kind, event.kind)' 2 times Locations: 0 1
  2. Pwa::SendNotificationsWorker#perform calls 'event.deal' 2 times Locations: 0 1
  3. Pwa::SendNotificationsWorker#perform calls 'event.kind' 2 times Locations: 0 1
  4. Pwa::SendNotificationsWorker#perform calls 'event.title' 2 times Locations: 0 1
icon: ActionController::Base.helpers.image_url('logo-patinha.svg'), url: Rails.application.routes.url_helpers.account_deal_url(Current.account, event.deal)
  1. Pwa::SendNotificationsWorker#perform calls 'event.deal' 2 times Locations: 0 1
} ) end end end end end