Sha256: cb14f967aa819a6bff41ee9f7dbf8dd2ee48b7bc124549c7b99667b73743e5b7

Contents?: true

Size: 1.27 KB

Versions: 23

Compression:

Stored size: 1.27 KB

Contents

# A wrapper around Naf::MachineRunner used for rendering in views

module Logical
  module Naf
    class MachineRunner

      COLUMNS = [
        'id',
        'created_at',
        'server_name',
        'runner_cwd'
      ]

      def self.to_array(column, order)
        machine_runners = []
        order_by = COLUMNS[column].to_s + ' ' + order
        ::Naf::MachineRunner.enabled.order(order_by).all.each do |runner|
          values = []
          runner.attributes.each do |key, value|
            if key == 'created_at'
              values << value.to_s
            else
              values << value
            end
          end

          invocation = runner.machine_runner_invocations.last
          values << invocation.id
          values << invocation.pid
          values << invocation.status.gsub('-', ' ').split.map(&:capitalize).join(' ')

          values << ::Naf::HistoricalJob.
            joins("inner join #{::Naf.schema_name}.running_jobs nj on nj.id = #{::Naf.schema_name}.historical_jobs.id").
            joins(:machine_runner_invocation).
            where("#{::Naf.schema_name}.machine_runner_invocations.machine_runner_id = ?", runner.id).count
          values << ''

          machine_runners << values
        end

        machine_runners
      end

    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
naf-2.1.13 app/models/logical/naf/machine_runner.rb
naf-2.1.12 app/models/logical/naf/machine_runner.rb
naf-2.1.11 app/models/logical/naf/machine_runner.rb
naf-2.1.10 app/models/logical/naf/machine_runner.rb
naf-2.1.9 app/models/logical/naf/machine_runner.rb
naf-2.1.8 app/models/logical/naf/machine_runner.rb
naf-2.1.6 app/models/logical/naf/machine_runner.rb
naf-2.1.5 app/models/logical/naf/machine_runner.rb
naf-2.1.4 app/models/logical/naf/machine_runner.rb
naf-2.1.3 app/models/logical/naf/machine_runner.rb
naf-2.1.2 app/models/logical/naf/machine_runner.rb
naf-2.1.1 app/models/logical/naf/machine_runner.rb
naf-2.1.0 app/models/logical/naf/machine_runner.rb
naf-2.0.4 app/models/logical/naf/machine_runner.rb
naf-2.0.3 app/models/logical/naf/machine_runner.rb
naf-2.0.2 app/models/logical/naf/machine_runner.rb
naf-2.0.1 app/models/logical/naf/machine_runner.rb
naf-2.0.0 app/models/logical/naf/machine_runner.rb
naf-1.1.4 app/models/logical/naf/machine_runner.rb
naf-1.1.3 app/models/logical/naf/machine_runner.rb