Class: RulesEngine::Process::DbRunner
- Defined in:
- lib/rules_engine/process/runner/db_runner.rb
Instance Method Summary collapse
- #create ⇒ Object
- #history(plan_code = nil, options = {}) ⇒ Object
-
#initialize(*options) ⇒ DbRunner
constructor
A new instance of DbRunner.
- #run_plan(process_id, plan, data = {}) ⇒ Object
- #status(process_id) ⇒ Object
Methods inherited from Runner
Constructor Details
#initialize(*options) ⇒ DbRunner
Returns a new instance of DbRunner.
27 28 |
# File 'lib/rules_engine/process/runner/db_runner.rb', line 27 def initialize(*) end |
Instance Method Details
#create ⇒ Object
30 31 32 |
# File 'lib/rules_engine/process/runner/db_runner.rb', line 30 def create() ReProcessRun.create(:process_status => RulesEngine::Process::PROCESS_STATUS_NONE).id end |
#history(plan_code = nil, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rules_engine/process/runner/db_runner.rb', line 57 def history(plan_code = nil, = {}) re_process_runs = ReProcessRun.history(plan_code, ) { "next_page" => re_process_runs.next_page, "previous_page" => re_process_runs.previous_page, "processes" => re_process_runs.map do |re_process_run| { "process_id" => re_process_run.id, "plan_code" => re_process_run.plan_code, "plan_version" => re_process_run.plan_version, "process_status" => re_process_run.process_status, "started_at" => re_process_run.started_at.nil? ? nil : re_process_run.started_at.utc.to_s, "finished_at" =>re_process_run.finished_at.nil? ? nil : re_process_run.finished_at.utc.to_s } end } end |
#run_plan(process_id, plan, data = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rules_engine/process/runner/db_runner.rb', line 34 def run_plan(process_id, plan, data = {}) re_process = ReProcessRun.find_by_id(process_id) if re_process.nil? RulesEngine::Process.auditor.audit(process_id, "Process missing", RulesEngine::Process::AUDIT_FAILURE) return false end re_process.update_attributes(:plan_code => plan["code"], :plan_version => plan["version"], :started_at => Time.now.utc, :process_status => RulesEngine::Process::PROCESS_STATUS_RUNNING) success = super(process_id, plan, data) re_process.update_attributes(:finished_at => Time.now.utc, :process_status => success ? RulesEngine::Process::PROCESS_STATUS_SUCCESS : RulesEngine::Process::PROCESS_STATUS_FAILURE) success end |
#status(process_id) ⇒ Object
51 52 53 54 |
# File 'lib/rules_engine/process/runner/db_runner.rb', line 51 def status(process_id) re_process = ReProcessRun.find_by_id(process_id) re_process ? re_process.process_status : RulesEngine::Process::PROCESS_STATUS_NONE end |