Class: Collavre::StuckDetectorJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/collavre/stuck_detector_job.rb

Overview

StuckDetectorJob runs periodically to detect stuck tasks and creatives.

This job should be scheduled to run every 5-10 minutes via cron or similar.

Usage:

StuckDetectorJob.perform_later

To schedule with SolidQueue:

# config/recurring.yml
stuck_detector:
  class: Collavre::StuckDetectorJob
  schedule: every 10 minutes

Instance Method Summary collapse

Instance Method Details

#performObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/jobs/collavre/stuck_detector_job.rb', line 20

def perform
  detector = Orchestration::StuckDetector.new
  result = detector.detect_and_escalate

  if result.escalated_count > 0
    Rails.logger.info(
      "[StuckDetectorJob] Detected #{result.stuck_items.count} stuck items, " \
      "escalated #{result.escalated_count}"
    )
  end

  result
end