Sha256: e167181694f3e234914fa2e283925bb75449984452bb3fbb08546df49bd99280

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

module RocketJobMissionControl
  class ActiveWorkersDatatable < AbstractDatatable
    delegate :job_path, :state_icon, to: :@view

    private

    def extract_query_params
      @query.order_by = nil
    end

    def map(active_worker)
      {
        '0'           => worker_name_with_icon(active_worker, active_worker.job),
        '1'           => job_name_with_link(active_worker.job.class.name, active_worker.job.id),
        '2'           => h(active_worker.job.description.try!(:truncate, 50)),
        '3'           => h("#{active_worker.duration} ago"),
        'DT_RowClass' => 'card callout callout-running'
      }
    end

    def worker_name_with_icon(active_worker, job)
      state = active_worker.zombie? ? :zombie : job.state
      <<-EOS
        <i class="#{state_icon(state)}" style="font-size: 75%" title="#{state}"></i>
        #{active_worker.name}
      EOS
    end

    def job_name_with_link(job_class_name, job_id)
      <<-EOS
        <a href="#{job_path(job_id)}">
          #{job_class_name}
        </a>
      EOS
    end

    def duration(started_at)
      "#{RocketJob.seconds_as_duration(Time.now - started_at)} ago" if started_at
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rocketjob_mission_control-4.3.0 app/datatables/rocket_job_mission_control/active_workers_datatable.rb
rocketjob_mission_control-4.2.1 app/datatables/rocket_job_mission_control/active_workers_datatable.rb
rocketjob_mission_control-4.2.0 app/datatables/rocket_job_mission_control/active_workers_datatable.rb
rocketjob_mission_control-4.1.0 app/datatables/rocket_job_mission_control/active_workers_datatable.rb
rocketjob_mission_control-4.0.0 app/datatables/rocket_job_mission_control/active_workers_datatable.rb
rocketjob_mission_control-3.2.0 app/datatables/rocket_job_mission_control/active_workers_datatable.rb
rocketjob_mission_control-3.1.0 app/datatables/rocket_job_mission_control/active_workers_datatable.rb