Module: Proxy::Dynflow::Helpers

Defined in:
lib/smart_proxy_dynflow/helpers.rb

Instance Method Summary collapse

Instance Method Details

#cancel_task(task_id) ⇒ Object



13
14
15
16
17
# File 'lib/smart_proxy_dynflow/helpers.rb', line 13

def cancel_task(task_id)
  execution_plan = world.persistence.load_execution_plan(task_id)
  cancel_events = execution_plan.cancel
  { :task_id => task_id, :canceled_steps_count => cancel_events.size }
end

#task_status(task_id) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/smart_proxy_dynflow/helpers.rb', line 19

def task_status(task_id)
  ep = world.persistence.load_execution_plan(task_id)
  ep.to_hash.merge(:actions => ep.actions.map(&:to_hash))
rescue KeyError => e
  status 404
  {}
end

#tasks_count(state) ⇒ Object



27
28
29
30
31
32
# File 'lib/smart_proxy_dynflow/helpers.rb', line 27

def tasks_count(state)
  state ||= 'all'
  filter = state != 'all' ? { :filters => { :state => [state] } } : {}
  tasks = world.persistence.find_execution_plans(filter)
  { :count => tasks.count, :state => state }
end

#trigger_task(*args) ⇒ Object



8
9
10
11
# File 'lib/smart_proxy_dynflow/helpers.rb', line 8

def trigger_task(*args)
  triggered = world.trigger(*args)
  { :task_id => triggered.id }
end

#worldObject



4
5
6
# File 'lib/smart_proxy_dynflow/helpers.rb', line 4

def world
  Proxy::Dynflow.world
end