75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/controllers/hyperlayer/events_controller.rb', line 75
def self.call(events, used_ids = [])
branches = []
current_branch = nil
events.each.with_index do |event, index|
if !used_ids.include?(event.id)
rest_of_events = events[(index + 1)..-1].select { |e| e.id < event.return_value_events&.id }
used_ids << event.id
current_branch = {
event => BuildTree.call(rest_of_events, used_ids)
}
branches.push(current_branch)
end
end
branches
end
|