Class: Tasker::WorkflowStepEdge
Class Method Summary
collapse
configure_database_connections, database_configuration_exists?
Class Method Details
.create_edge!(from_step, to_step, name) ⇒ Object
18
19
20
|
# File 'app/models/tasker/workflow_step_edge.rb', line 18
def self.create_edge!(from_step, to_step, name)
create!(from_step: from_step, to_step: to_step, name: name)
end
|
.sibling_sql(step_id) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/models/tasker/workflow_step_edge.rb', line 22
def self.sibling_sql(step_id)
sanitized_id = connection.quote(step_id)
<<~SQL.squish
WITH step_parents AS (
SELECT from_step_id
FROM tasker_workflow_step_edges
WHERE to_step_id = #{sanitized_id}
),
potential_siblings AS (
SELECT to_step_id
FROM tasker_workflow_step_edges
WHERE from_step_id IN (SELECT from_step_id FROM step_parents)
AND to_step_id != #{sanitized_id}
),
siblings AS (
SELECT to_step_id
FROM tasker_workflow_step_edges
WHERE to_step_id IN (SELECT to_step_id FROM potential_siblings)
GROUP BY to_step_id
HAVING ARRAY_AGG(from_step_id ORDER BY from_step_id) =
(SELECT ARRAY_AGG(from_step_id ORDER BY from_step_id) FROM step_parents)
)
SELECT e.*
FROM tasker_workflow_step_edges e
JOIN siblings ON e.to_step_id = siblings.to_step_id
SQL
end
|