Sha256: f5bd237ecac04ae1dbb8a5f518fa02bd6a3fb762ab0a4334637eb2d3ac94037f

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

module InternalAffairs
  class PendingOperationsUpdateJob < ::ActiveJob::Base
    def perform
      InternalAffairs::PendingOperation.all.find_each do |operation|
        update_operation operation
      end
    end

    private

    def update_operation(_operation)
      operation = InternalAffairs::ApiUtils.get_operation _operation.operation_uuid

      ActiveRecord::Base.transaction do
        case operation.state
        when 'approved'
          _operation.target.approve!
          _operation.destroy
        when 'rejected'
          _operation.target.reject!
          _operation.destroy
        end
      end
    rescue StandardError => e
      Raven.capture_exception e
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
internal-affairs-1.0.1 lib/internal_affairs/pending_operations_update_job.rb
internal-affairs-1.0.0 lib/internal_affairs/pending_operations_update_job.rb