Updated

app/jobs / reset_petition_signature_count_job.rb

A
28 lines of codes
5 methods
3.2 complexity/method
1 churn
15.92 complexity
0 duplications
class ResetPetitionSignatureCountJob < ApplicationJob
  1. ResetPetitionSignatureCountJob has no descriptive comment
class InvalidSignatureCount < RuntimeError; end
  1. ResetPetitionSignatureCountJob::InvalidSignatureCount has no descriptive comment
queue_as :highest_priority def perform(petition, time = current_time) petition.reset_signature_count!(time.in_time_zone) send_notification(petition) end private def current_time
  1. ResetPetitionSignatureCountJob#current_time doesn't depend on instance state (maybe move it to another class?)
Time.current.change(usec: 0).iso8601 end def send_notification(petition) Appsignal.send_exception(exception(petition)) end def exception(petition) InvalidSignatureCount.new(error_message(petition)) end def error_message(petition)
  1. ResetPetitionSignatureCountJob#error_message doesn't depend on instance state (maybe move it to another class?)
I18n.t(:"invalid_signature_count", scope: :"petitions.errors", id: petition.id.to_s) end end