Updated

app/jobs / notify_trending_domain_job.rb

B
54 lines of codes
9 methods
4.4 complexity/method
4 churn
39.34 complexity
27 duplications
require 'slack-notifier' class NotifyTrendingDomainJob < ApplicationJob
  1. NotifyTrendingDomainJob has no descriptive comment
include Rails.application.routes.url_helpers queue_as :low_priority delegate :trending_items_notification_url, to: :rate_limit def perform(domain) slack.ping(message(domain)) end private def message(domain)
  1. Similar code found in 2 nodes Locations: 0 1
  2. NotifyTrendingDomainJob#message has approx 7 statements
params = [] params << domain.count
  1. NotifyTrendingDomainJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << start_time(domain)
  1. NotifyTrendingDomainJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << end_time(domain)
  1. NotifyTrendingDomainJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << petition_link(domain)
  1. NotifyTrendingDomainJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
params << domain_address_link(domain)
  1. NotifyTrendingDomainJob#message refers to 'params' more than self (maybe move it to another class?) Locations: 0 1 2 3 4
"%d signatures between %s and %s on %s from %s" % params end def rate_limit @rate_limit ||= RateLimit.first_or_create! end def slack @slack ||= Slack::Notifier.new(trending_items_notification_url) end def time_format "%-I:%M%P" end def start_time(domain) domain.starts_at.strftime(time_format) end def end_time(domain) domain.ends_at.strftime(time_format) end def petition_link(domain) "<#{admin_petition_url(domain.petition)}|#{domain.petition.action}>"
  1. NotifyTrendingDomainJob#petition_link calls 'domain.petition' 2 times
  2. NotifyTrendingDomainJob#petition_link refers to 'domain' more than self (maybe move it to another class?)
end def domain_address_link(domain) "<#{admin_petition_signatures_url(domain.petition, q: "@#{domain.domain}", window: domain.window)}|#{domain.domain}>"
  1. NotifyTrendingDomainJob#domain_address_link calls 'domain.domain' 2 times
  2. NotifyTrendingDomainJob#domain_address_link refers to 'domain' more than self (maybe move it to another class?)
end end