Skip to content

Commit

Permalink
testing JSON now shows the *expected* suspends.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 12, 2024
1 parent 6fa7de4 commit 628cecf
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 121 deletions.
18 changes: 11 additions & 7 deletions lib/trailblazer/workflow/state/discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ def self.generate_from(states)
row = lane_positions.flat_map do |activity, suspend|
next if suspend.to_h["resumes"].nil?

resumes = suspend.to_h["resumes"].collect do |catch_event_id|
catch_event = Trailblazer::Activity::Introspect.Nodes(activity, id: catch_event_id).task
# task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right]
# # raise task_after_catch.inspect

# Trailblazer::Activity::Introspect.Nodes(activity, task: task_after_catch).data[:label] || task_after_catch
end
resumes = resumes_from_suspend(activity, suspend)

# [
# lanes[activity],
Expand All @@ -53,7 +47,17 @@ def self.generate_from(states)

Present::State.new(start_position, row, state)
end
end

# Compute real catch events from the ID for a particular resume.
def self.resumes_from_suspend(activity, suspend)
suspend.to_h["resumes"].collect do |catch_event_id|
_catch_event = Trailblazer::Activity::Introspect.Nodes(activity, id: catch_event_id).task
# task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right]
# # raise task_after_catch.inspect

# Trailblazer::Activity::Introspect.Nodes(activity, task: task_after_catch).data[:label] || task_after_catch
end
end
end # Discovery
end
Expand Down
25 changes: 10 additions & 15 deletions lib/trailblazer/workflow/state/discovery/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,43 @@ def self.render_json(states, lanes:, additional_state_data:, initial_lane_positi
present_states = Trailblazer::Workflow::State::Discovery.generate_from(states) # returns rows with [{activity, suspend, resumes}]

rows = present_states.collect do |state| # state = {start_position, lane_states: [{activity, suspend, resumes}]}
# raise state.inspect

start_position, lane_positions, discovery_state_fixme = state.to_a

# "serialize" start task
activity_id, triggered_catch_event_id = id_tuple_for(lanes, start_position.activity, start_position.task)

# {suspend_configuration} are the lane positions after we started running from {start_position}.
suspend_configuration = additional_state_data[[state.state_from_discovery_fixme.object_id, :suspend_configuration]]


# Go through each lane and define the expected positions after running from the start position.
expected_lane_positions = lane_positions.collect do |lane_position|
expected_lane_positions = suspend_configuration.lane_positions.collect do |lane_position|
next if lane_position.nil? # FIXME: why do we have that?

# puts lane_position[:suspend] # DISCUSS: introduce State::Position? this comes from {#generate_from}.
activity, suspend = lane_position



if initial_lane_positions.invert[lane_position[:suspend]]
if initial_lane_positions.invert[suspend]
{
tuple: [lanes[lane_position[:activity]], nil], # FIXME: to indicate this is a virtual "task".
tuple: [lanes[activity], nil], # FIXME: to indicate this is a virtual "task".
}
else
position_tuple = id_tuple_for(lanes, lane_position[:activity], lane_position[:suspend]) # usually, this is a suspend.
next if suspend.to_h["resumes"].nil? # FIXME: for termini.

position_tuple = id_tuple_for(lanes, activity, suspend) # usually, this is a suspend.

# Compute the task name that follows a particular catch event.
activity = lane_position[:activity]
resumes = lane_position[:resumes]#.to_h["resumes"]
resumes = Discovery.resumes_from_suspend(activity, suspend)

resumes_label = resumes.collect do |catch_event|
puts "@@@@@ #{catch_event.inspect}"

task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right]
# raise task_after_catch.inspect

Trailblazer::Activity::Introspect.Nodes(activity, task: task_after_catch).data[:label] || task_after_catch
end



# _, task_id = position_tuple


comment = resumes_label
# task_map.invert.each do |id, label|
# if task_id =~ /#{id}$/
Expand Down
Loading

0 comments on commit 628cecf

Please sign in to comment.