1class ResetPetitionSignatureCountJob < ApplicationJob
 
2  class InvalidSignatureCount < RuntimeError; end
 
3
 
4  queue_as :highest_priority
 
5
  • Complexity 1 » saikuro
6  def perform(petition, time = current_time)
 
7    petition.reset_signature_count!(time.in_time_zone)
 
8    send_notification(petition)
 
 9  end
 
 
11  private
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
13  def current_time
 
14    Time.current.change(usec: 0).iso8601
 
15  end
 
  • Complexity 1 » saikuro
17  def send_notification(petition)
 
18    Appsignal.send_exception(exception(petition))
 
19  end
 
  • Complexity 1 » saikuro
21  def exception(petition)
 
22    InvalidSignatureCount.new(error_message(petition))
 
23  end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
25  def error_message(petition)
 
26    I18n.t(:"invalid_signature_count", scope: :"petitions.errors", id: petition.id.to_s)
 
27  end
 
28end