1class PetitionCountJob < ApplicationJob
 
2  delegate :signature_count_interval, to: :Site
 
3  delegate :disable_invalid_signature_count_check?, to: :Site
 
4
 
5  queue_as :highest_priority
 
6
  • Complexity 4 » saikuro
7  def perform(now = current_time)
 
8    return if disable_invalid_signature_count_check?
 
 9
 
10    petitions.find_each do |petition|
 
11      unless petition.valid_signature_count!
 
12        ResetPetitionSignatureCountJob.perform_later(petition, now)
 
13      end
 
14    end
 
15  end
 
 
17  private
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
19  def current_time
 
20    Time.current.change(usec: 0).iso8601
 
21  end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
23  def petitions
 
24    Petition.in_need_of_validating
 
25  end
 
26end