|
1require 'slack-notifier'
|
|
|
|
3class NotifyTrendingIpJob < ApplicationJob
|
|
4 include Rails.application.routes.url_helpers
|
|
|
|
|
|
|
|
8 delegate :trending_items_notification_url, to: :rate_limit
|
|
|
|
|
|
11 slack.ping(message(ip))
|
|
|
|
|
|
|
|
|
- FeatureEnvy - refers to 'params' more than self (maybe move it to another class?) » reek
- TooManyStatements - has approx 7 statements » reek
- Complexity 1 » saikuro
|
|
|
|
|
|
|
19 params << start_time(ip)
|
|
20 params << end_time(ip)
|
|
21 params << petition_link(ip)
|
|
22 params << ip_address_link(ip)
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 ip.starts_at.strftime(time_format)
|
|
|
|
|
|
|
|
44 ip.ends_at.strftime(time_format)
|
|
|
|
|
- DuplicateMethodCall - calls 'ip.petition' 2 times » reek
- FeatureEnvy - refers to 'ip' more than self (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
|
|
48 "<#{admin_petition_url(ip.petition)}|#{ip.petition.action}>"
|
|
|
|
|
- DuplicateMethodCall - calls 'ip.ip_address' 2 times » reek
- FeatureEnvy - refers to 'ip' more than self (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
51 def ip_address_link(ip)
|
|
52 "<#{admin_petition_signatures_url(ip.petition, q: ip.ip_address, window: ip.window)}|#{ip.ip_address}>"
|
|
|
|
|