lib/legion/extensions/tasker/runners/check_subtask.rb in lex-tasker-0.1.1 vs lib/legion/extensions/tasker/runners/check_subtask.rb in lex-tasker-0.1.2

- old
+ new

@@ -4,14 +4,14 @@ module Runners module CheckSubtask include Legion::Extensions::Helpers::Lex def check_subtasks(runner_class:, function:, **opts) - runner_record = Legion::Data::Model::Runner.where(namespace: runner_class).first + runner_record = Legion::Data::Model::Runner[namespace: runner_class] return if runner_record.nil? - function_record = runner_record.functions_dataset.where(name: function).first + function_record = runner_record.functions_dataset[name: function] return if function_record.nil? relationships = function_record.trigger_relationships_dataset.where(:active) relationships.where(chain_id: opts[:chain_id] || :allow_new_chains) if opts.key? :chain_id return { success: true, count: relationships.count } if relationships.count.zero? @@ -90,9 +90,17 @@ transformation: relationship.values[:transformation], debug: relationship.values[:debug] && 1 || 0, task_id: task_id, results: opts[:result] } + + subtask_hash[:routing_key] = if subtask_hash[:conditions].is_a?(String) && subtask_hash[:conditioners].length > 4 # rubocop:disable Layout/LineLength + 'task.subtask.conditioner' + elsif subtask_hash[:transformation].is_a?(String) && subtask_hash[:transformation].length > 4 # rubocop:disable Layout/LineLength + 'task.subtask.transform' + else + "#{runner_record.extension.values[:exchange]}.#{runner_record.values[:queue]}.#{subtask_hash[:function]}" # rubocop:disable Layout/LineLength + end subtask_hash[:success] = if opts.nil? 1 elsif opts.key?(:result) # opts[:result][:success]