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)
" WITH step_parents AS (\n SELECT from_step_id\n FROM tasker_workflow_step_edges\n WHERE to_step_id = \#{sanitized_id}\n ),\n potential_siblings AS (\n SELECT to_step_id\n FROM tasker_workflow_step_edges\n WHERE from_step_id IN (SELECT from_step_id FROM step_parents)\n AND to_step_id != \#{sanitized_id}\n ),\n siblings AS (\n SELECT to_step_id\n FROM tasker_workflow_step_edges\n WHERE to_step_id IN (SELECT to_step_id FROM potential_siblings)\n GROUP BY to_step_id\n HAVING ARRAY_AGG(from_step_id ORDER BY from_step_id) =\n (SELECT ARRAY_AGG(from_step_id ORDER BY from_step_id) FROM step_parents)\n )\n SELECT e.*\n FROM tasker_workflow_step_edges e\n JOIN siblings ON e.to_step_id = siblings.to_step_id\n SQL\nend\n".squish
|