Class: Tasker::Functions::FunctionBasedDependencyLevels
- Inherits:
-
FunctionWrapper
- Object
- FunctionWrapper
- Tasker::Functions::FunctionBasedDependencyLevels
- Defined in:
- lib/tasker/functions/function_based_dependency_levels.rb
Overview
Function-based implementation of dependency level calculation Uses SQL function for performance-optimized dependency level calculation
Class Method Summary collapse
-
.for_task(task_id) ⇒ Object
Class methods that use SQL functions.
- .levels_hash_for_task(task_id) ⇒ Object
- .max_level_for_task(task_id) ⇒ Object
- .root_steps_for_task(task_id) ⇒ Object
- .steps_at_level(task_id, level) ⇒ Object
Instance Method Summary collapse
-
#to_h ⇒ Object
Instance methods.
-
#workflow_step ⇒ Object
Associations (lazy-loaded).
Methods inherited from FunctionWrapper
connection, convert_array_bind, from_sql_function, #readonly?, single_from_sql_function
Class Method Details
.for_task(task_id) ⇒ Object
Class methods that use SQL functions
15 16 17 18 19 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 15 def self.for_task(task_id) sql = 'SELECT * FROM calculate_dependency_levels($1::BIGINT)' binds = [task_id] from_sql_function(sql, binds, 'DependencyLevels Load') end |
.levels_hash_for_task(task_id) ⇒ Object
21 22 23 24 25 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 21 def self.levels_hash_for_task(task_id) for_task(task_id).each_with_object({}) do |level_data, hash| hash[level_data.workflow_step_id] = level_data.dependency_level end end |
.max_level_for_task(task_id) ⇒ Object
27 28 29 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 27 def self.max_level_for_task(task_id) for_task(task_id).map(&:dependency_level).max || 0 end |
.root_steps_for_task(task_id) ⇒ Object
36 37 38 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 36 def self.root_steps_for_task(task_id) steps_at_level(task_id, 0) end |
.steps_at_level(task_id, level) ⇒ Object
31 32 33 34 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 31 def self.steps_at_level(task_id, level) for_task(task_id).select { |data| data.dependency_level == level } .map(&:workflow_step_id) end |
Instance Method Details
#to_h ⇒ Object
Instance methods
41 42 43 44 45 46 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 41 def to_h { workflow_step_id: workflow_step_id, dependency_level: dependency_level } end |
#workflow_step ⇒ Object
Associations (lazy-loaded)
49 50 51 |
# File 'lib/tasker/functions/function_based_dependency_levels.rb', line 49 def workflow_step @workflow_step ||= Tasker::WorkflowStep.find(workflow_step_id) end |