app/helpers/jobs_helper.rb
# Given an queued job, parse the stored YAML to retrieve the ID of the Agent
# meant to be ran.
#
# Can return nil, or an instance of Agent.
Given an queued job, parse the stored YAML to retrieve the ID of the Agent
meant to be ran.

Can return nil, or an instance of Agent.
Given an queued job parse the stored YAML to retrieve the ID of the Agent meant to be ran . Can return nil or an instance of Agent .
def agent_from_job(job)
    data = YAML.load(job.handler.to_s).try(:job_data)
    case data['job_class']
    when 'AgentCheckJob', 'AgentReceiveJob'
      Agent.find_by_id(data['arguments'][0])
    when 'AgentRunScheduleJob'
      "Run Agent schedule '#{data['arguments'][0]}'"
    when 'AgentCleanupExpiredJob'
      'Run Event cleanup'
    when 'AgentPropagateJob'
      'Run Event propagation'
    else
      false
    end
  rescue ArgumentError
    nil
  end
def agent_from_job ( job ) data = YAML . load ( job . handler . to_s ) . try ( :job_data ) case data [ 'job_class' ] when 'AgentCheckJob' , 'AgentReceiveJob' Agent . find_by_id ( data [ 'arguments' ] [ 0 ] ) when 'AgentRunScheduleJob' "Run Agent schedule '#{data['arguments'][0]}'" when 'AgentCleanupExpiredJob' 'Run Event cleanup' when 'AgentPropagateJob' 'Run Event propagation' else false end rescue ArgumentError nil end
Given an queued job, parse the stored YAML to retrieve the ID of the Agent
meant to be ran.
Given an queued job parse the stored YAML to retrieve the ID of the Agent meant to be ran .
# We can get to this point before all of the agents have loaded (usually, # in development)
job
<not_specific>