Skip to content

Commit

Permalink
Fixes sub plans querying
Browse files Browse the repository at this point in the history
The old behavior was to cache the results of WithSubPlans#sub_plans,
which was confusing when using filters. For example
action.sub_plans(:state => :stopped)
action.sub_plans(:state => 'non-existent state')
would return all sub plans in :stopped state twice.
  • Loading branch information
adamruzicka committed Jul 27, 2017
1 parent 1297e75 commit fdf57ed
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/dynflow/action/with_sub_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ def resume
end

def sub_plans(filter = {})
@sub_plans ||= world.persistence.find_execution_plans(filters: { 'caller_execution_plan_id' => execution_plan_id,
'caller_action_id' => self.id }.merge(filter) )
filters = { 'caller_execution_plan_id' => execution_plan_id,
'caller_action_id' => self.id }
if filter.empty?
@sub_plans ||= world.persistence.find_execution_plans(filters: filters)
else
world.persistence.find_execution_plans(filters: filters.merge(filter))
end
end

def notify_on_finish(plans)
Expand Down

0 comments on commit fdf57ed

Please sign in to comment.