summaryrefslogtreecommitdiff
path: root/app/helpers/runners_helper.rb
blob: 0d6e982d660b82d4a31741b5fcef8f78470675ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module RunnersHelper
  def runner_status_icon(runner)
    unless runner.contacted_at
      return content_tag :i, nil,
        class: "icon-warning-sign",
        title: "New runner. Has not connected yet"
    end

    status =
      if runner.active?
        runner.contacted_at > 3.hour.ago ? :online : :offline
      else
        :paused
      end

    content_tag :i, nil,
      class: "icon-circle runner-status-#{status}",
      title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago"
  end
end