Class: JobWorkflow::Monitoring::ExecutionViewModel

Inherits:
Object
  • Object
show all
Defined in:
lib/job_workflow/monitoring/execution_view_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_id:, queue_name:, status:) ⇒ ExecutionViewModel

: (job_id: String, queue_name: String?, status: WorkflowStatus) -> void



11
12
13
14
15
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 11

def initialize(job_id:, queue_name:, status:)
  @job_id = job_id
  @queue_name = queue_name
  @status = status
end

Instance Attribute Details

#job_idObject (readonly)

: String



6
7
8
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 6

def job_id
  @job_id
end

#queue_nameObject (readonly)

: String?



7
8
9
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 7

def queue_name
  @queue_name
end

#statusObject (readonly)

: WorkflowStatus



8
9
10
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 8

def status
  @status
end

Instance Method Details

#argumentsObject

: () -> Arguments



33
34
35
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 33

def arguments
  status.arguments
end

#current_task_nameObject

: () -> Symbol?



28
29
30
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 28

def current_task_name
  status.current_task_name
end

#dag_layoutObject

: () -> Hash[Symbol, untyped]



61
62
63
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 61

def dag_layout
  @dag_layout ||= DagLayout.new(tasks:).to_h
end

#failed_task_nameObject

: () -> Symbol?



48
49
50
51
52
53
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 48

def failed_task_name
  @failed_task_name ||= begin
    failed_task = tasks.find { |task| task[:status] == :failed }
    failed_task&.fetch(:name)
  end
end

#filtered_argumentsObject

: () -> Hash[untyped, untyped]



38
39
40
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 38

def filtered_arguments
  ParameterFilter.filter(arguments.to_h)
end

#job_class_nameObject

: () -> String



18
19
20
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 18

def job_class_name
  status.job_class_name
end

#mission_control_job_pathObject

: () -> String?



56
57
58
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 56

def mission_control_job_path
  JobWorkflow::Monitoring.mission_control_job_path(job_id, status: workflow_status)
end

#running?Boolean

: () -> bool

Returns:

  • (Boolean)


66
67
68
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 66

def running?
  workflow_status == :running
end

#tasksObject

: () -> Array[Hash[Symbol, untyped]]



43
44
45
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 43

def tasks
  @tasks ||= status.context.workflow.tasks.map { |task| task_view_model(task) }
end

#to_hObject

: () -> Hash[Symbol, untyped]



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 71

def to_h
  {
    job_id:,
    queue_name:,
    job_class_name:,
    status: workflow_status,
    current_task_name:,
    failed_task_name:,
    arguments: filtered_arguments,
    tasks:,
    mission_control_job_path:
  }
end

#workflow_statusObject

: () -> Symbol



23
24
25
# File 'lib/job_workflow/monitoring/execution_view_model.rb', line 23

def workflow_status
  status.status
end