Class: DailyFocusAnalysisWorker

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

Overview

Nightly orchestrator that fans out Daily Focus Analysis generation
to one DailyFocusAnalysisRepWorker per active sales rep, then
enqueues the manager digest report after a delay.

Scheduled at 5:00 AM CT (after the 4:00 AM activity prioritizer).

Constant Summary collapse

MANAGER_REPORT_DELAY =
20.minutes

Instance Method Summary collapse

Instance Method Details

#performObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/daily_focus_analysis_worker.rb', line 16

def perform
  targets = DailyFocus::RunPolicy.new(date: Date.current).automation_targets

  Rails.logger.info("[DailyFocusAnalysisWorker] Enqueuing daily focus for #{targets.size} automation targets " \
                    "(policy: schedule + backup coverage)")

  targets.each_with_index do |target, index|
    DailyFocusAnalysisRepWorker.perform_in(
      index * 30.seconds,
      target.primary_employee_id,
      nil,
      target.covered_employee_ids
    )
  end

  DailyFocusManagerReportWorker.perform_in(MANAGER_REPORT_DELAY)

  Rails.logger.info("[DailyFocusAnalysisWorker] All jobs enqueued")
end