Sha256: 7595453d9fc287845f787efde521ae8853d5da8ed14277cefcd71e132e6107c6

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

module Legion::Extensions::Tasker
  module Runners
    module Updater
      include Legion::Extensions::Helpers::Lex

      def update_status(task_id:, **opts)
        task = Legion::Data::Model::Task[task_id]
        update_hash = {}
        %i[status function_args payload results].each do |column|
          next unless opts.key? column

          update_hash[column] = if opts[column].is_a? String
                                  opts[column]
                                else
                                  to_json opts[column]
                                end
        end
        { success: true, changed: false, task_id: task_id } if update_hash.count.zero?
        task.update(update_hash)

        { success: true, changed: true, task_id: task_id, updates: update_hash }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lex-tasker-0.1.3 lib/legion/extensions/tasker/runners/updater.rb
lex-tasker-0.1.2 lib/legion/extensions/tasker/runners/updater.rb
lex-tasker-0.1.1 lib/legion/extensions/tasker/runners/updater.rb