Class: CampaignEmailClickScoringWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/campaign_email_click_scoring_worker.rb

Overview

Sidekiq worker: score a campaign email's clicks for security-scanner traffic.

Enqueued (delayed by SCORING_DELAY) when a CampaignEmail reaches transmitted,
so the bulk of both human and scanner clicks have landed before we aggregate.
Idempotent — re-running recomputes CommunicationRecipient#machine_clicked from
the current click data, so it is safe to replay.

Constant Summary collapse

SCORING_DELAY =

How long after a send completes to score it. Most scanner and human clicks
arrive within hours; the pass is recomputable if late clicks matter.

6.hours

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enqueue_for(campaign_email) ⇒ void

This method returns an undefined value.

Schedule scoring for a send once it has finished transmitting.

Parameters:



22
23
24
# File 'app/workers/campaign_email_click_scoring_worker.rb', line 22

def self.enqueue_for(campaign_email)
  perform_in(SCORING_DELAY, campaign_email.id)
end

Instance Method Details

#perform(campaign_email_id) ⇒ void

This method returns an undefined value.

Parameters:

  • campaign_email_id (Integer)


28
29
30
31
32
33
# File 'app/workers/campaign_email_click_scoring_worker.rb', line 28

def perform(campaign_email_id)
  campaign_email = CampaignEmail.find_by(id: campaign_email_id)
  return unless campaign_email

  Communication::ClickBotScorer.for_campaign(campaign_email).process
end