|
1require 'slack-notifier'
|
|
|
|
3class NotifyTrendingDomainJob < ApplicationJob
|
|
4 include Rails.application.routes.url_helpers
|
|
|
|
|
|
|
|
8 delegate :trending_items_notification_url, to: :rate_limit
|
|
|
|
|
|
11 slack.ping(message(domain))
|
|
|
|
|
|
|
|
|
- FeatureEnvy - refers to 'params' more than self (maybe move it to another class?) » reek
- TooManyStatements - has approx 7 statements » reek
- Complexity 1 » saikuro
|
|
|
|
|
18 params << domain.count
|
|
19 params << start_time(domain)
|
|
20 params << end_time(domain)
|
|
21 params << petition_link(domain)
|
|
22 params << domain_address_link(domain)
|
|
|
|
24 "%d signatures between %s and %s on %s from %s" % params
|
|
|
|
|
|
|
|
28 @rate_limit ||= RateLimit.first_or_create!
|
|
|
|
|
|
|
|
32 @slack ||= Slack::Notifier.new(trending_items_notification_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 def start_time(domain)
|
|
40 domain.starts_at.strftime(time_format)
|
|
|
|
|
|
|
|
44 domain.ends_at.strftime(time_format)
|
|
|
|
|
- DuplicateMethodCall - calls 'domain.petition' 2 times » reek
- FeatureEnvy - refers to 'domain' more than self (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
47 def petition_link(domain)
|
|
48 "<#{admin_petition_url(domain.petition)}|#{domain.petition.action}>"
|
|
|
|
|
- DuplicateMethodCall - calls 'domain.domain' 2 times » reek
- FeatureEnvy - refers to 'domain' more than self (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
51 def domain_address_link(domain)
|
|
52 "<#{admin_petition_signatures_url(domain.petition, q: "@#{domain.domain}", window: domain.window)}|#{domain.domain}>"
|
|
|
|
|