Class: Tasker::Functions::FunctionBasedTaskExecutionContext
Overview
Function-based implementation of TaskExecutionContext
Maintains the same interface as the view-based model but uses SQL functions for performance
Class Method Summary
collapse
Instance Method Summary
collapse
connection, convert_array_bind, from_sql_function, #readonly?, single_from_sql_function
Class Method Details
.find(task_id) ⇒ Object
Class methods that use SQL functions
26
27
28
29
30
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 26
def self.find(task_id)
sql = 'SELECT * FROM get_task_execution_context($1::BIGINT)'
binds = [task_id]
single_from_sql_function(sql, binds, 'TaskExecutionContext Load')
end
|
.for_tasks(task_ids) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 32
def self.for_tasks(task_ids)
return [] if task_ids.empty?
sql = 'SELECT * FROM get_task_execution_contexts_batch($1::BIGINT[])'
binds = [task_ids]
from_sql_function(sql, binds, 'TaskExecutionContext Batch Load')
end
|
Instance Method Details
#can_make_progress? ⇒ Boolean
63
64
65
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 63
def can_make_progress?
ready_steps.positive?
end
|
#has_work_to_do? ⇒ Boolean
Helper methods for workflow decision making (same as original model)
#needs_intervention? ⇒ Boolean
#next_action_details ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 102
def next_action_details
case recommended_action
when Constants::TaskExecution::RecommendedAction::EXECUTE_READY_STEPS
{
action: Constants::TaskExecution::RecommendedAction::EXECUTE_READY_STEPS,
description: "#{ready_steps} steps ready for execution",
urgency: 'high',
can_proceed: true
}
when Constants::TaskExecution::RecommendedAction::WAIT_FOR_COMPLETION
{
action: Constants::TaskExecution::RecommendedAction::WAIT_FOR_COMPLETION,
description: "#{in_progress_steps} steps currently processing",
urgency: 'low',
can_proceed: false
}
when Constants::TaskExecution::RecommendedAction::HANDLE_FAILURES
{
action: Constants::TaskExecution::RecommendedAction::HANDLE_FAILURES,
description: "#{failed_steps} failed steps blocking progress",
urgency: 'critical',
can_proceed: false
}
when Constants::TaskExecution::RecommendedAction::FINALIZE_TASK
{
action: Constants::TaskExecution::RecommendedAction::FINALIZE_TASK,
description: 'All steps completed successfully',
urgency: 'medium',
can_proceed: true
}
else
{
action: Constants::TaskExecution::RecommendedAction::WAIT_FOR_DEPENDENCIES,
description: 'Waiting for dependencies to be satisfied',
urgency: 'low',
can_proceed: false
}
end
end
|
#progress_details ⇒ Object
92
93
94
95
96
97
98
99
100
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 92
def progress_details
{
completed_ratio: "#{completed_steps}/#{total_steps}",
completion_percentage: "#{completion_percentage}%",
remaining_steps: total_steps - completed_steps,
failed_steps: failed_steps,
ready_steps: ready_steps
}
end
|
#should_reenqueue? ⇒ Boolean
#task ⇒ Object
Association (lazy-loaded)
143
144
145
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 143
def task
@task ||= Tasker::Task.find(task_id)
end
|
#workflow_summary ⇒ Object
Status summary methods (same as original model)
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/tasker/functions/function_based_task_execution_context.rb', line 76
def workflow_summary
{
total_steps: total_steps,
completed: completed_steps,
pending: pending_steps,
in_progress: in_progress_steps,
failed: failed_steps,
ready: ready_steps,
completion_percentage: completion_percentage,
status: execution_status,
health: health_status,
recommended_action: recommended_action,
progress_details: progress_details
}
end
|