1class NotifyEveryoneOfModerationDecisionJob < ApplicationJob
 
2  rescue_from StandardError do |exception|
 
3    Appsignal.send_exception exception
 
4  end
 
5
  • FeatureEnvy - refers to 'petition' more than self (maybe move it to another class?) » reek
  • Complexity 3 » saikuro
6  def perform(petition)
 
7    creator = petition.creator
 
8    sponsors = petition.sponsors.validated
 
 9
 
10    if petition.published?
 
11      notify_everyone_of_publication(creator, sponsors)
 
12    elsif petition.rejected? || petition.hidden?
 
13      notify_everyone_of_rejection(creator, sponsors)
 
14    end
 
15  end
 
 
17  private
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 2 » saikuro
19  def notify_everyone_of_publication(creator, sponsors)
 
20    NotifyCreatorThatPetitionIsPublishedEmailJob.perform_later(creator)
 
 
22    sponsors.each do |sponsor|
 
23      NotifySponsorThatPetitionIsPublishedEmailJob.perform_later(sponsor)
 
24    end
 
25  end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 2 » saikuro
27  def notify_everyone_of_rejection(creator, sponsors)
 
28    NotifyCreatorThatPetitionWasRejectedEmailJob.perform_later(creator)
 
 
30    sponsors.each do |sponsor|
 
31      NotifySponsorThatPetitionWasRejectedEmailJob.perform_later(sponsor)
 
32    end
 
33  end
 
34end