lib/legion/extensions/conditioner/runners/conditioner.rb in lex-conditioner-0.2.0 vs lib/legion/extensions/conditioner/runners/conditioner.rb in lex-conditioner-0.2.1

- old
+ new

@@ -1,11 +1,11 @@ require 'legion/extensions/conditioner/helpers/condition' module Legion::Extensions::Conditioner module Runners module Conditioner - def self.check(**payload) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity + def self.check(**payload) # rubocop:disable Metrics/AbcSize conditioner = Legion::Extensions::Conditioner::Condition.new(conditions: payload[:conditions], task_id: payload[:task_id], values: payload, type: payload[:type]) if conditioner.valid? @@ -13,13 +13,11 @@ status = 'task.queued' else status = 'conditioner.failed' end - unless payload[:task_id].nil? - Legion::Transport::Messages::TaskUpdate.new(task_id: payload[:task_id], status: status).publish - end + task_update(payload[:task_id], status, **payload) unless payload[:task_id].nil? if payload[:debug] && payload.key?(:task_id) generate_task_log(task_id: payload[:task_id], function: 'check', valid: conditioner.valid?, @@ -35,15 +33,10 @@ unless payload[:task_id].nil? Legion::Transport::Messages::TaskUpdate.new(task_id: payload[:task_id], status: 'conditioner.failed').publish end end - def self.generate_task_log(task_id:, runner_class: to_s, function:, **payload) - require 'legion/transport/messages/task_log' - Legion::Transport::Messages::TaskLog.new(task_id: task_id, - runner_class: runner_class, - function: function, - entry: payload).publish - end + include Legion::Extensions::Helpers::Lex + include Legion::Extensions::Helpers::Task end end end