Sha256: 53e25446de86a8e1b2852ffe5292c4ed6a84a4eff327549b575776ba8e170d10

Contents?: true

Size: 703 Bytes

Versions: 4

Compression:

Stored size: 703 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
      Sentry.capture_exception e
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
internal-affairs-1.2.0 lib/internal_affairs/pending_operations_update_job.rb
internal-affairs-1.1.2 lib/internal_affairs/pending_operations_update_job.rb
internal-affairs-1.1.1 lib/internal_affairs/pending_operations_update_job.rb
internal-affairs-1.1.0 lib/internal_affairs/pending_operations_update_job.rb