Sha256: c364305641d50ce7c7a2d1d3336ba410af3e362158d4ee09d1e5e357ee6bf3f6

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module JobHelper

  def when_full(s)
    !s ? '-' : s.strftime('%a %b %d %H:%M')
  end

  def when_tiny(s)
    !s ? '-' : s.strftime('%H:%M %a')
  end

  def human_size_if_nz(val)
    val <= 0 ? '-' : number_to_human_size(val)
  end

  def secs_to_hms(sec)
    return '-' if sec <= 0
    s = sec.divmod(60)
    m = s[0].divmod(60)
    sprintf '%d:%02d:%02d', m[0], m[1], s[1]
  end

  def type_name(c)
    name = {
      'B' => 'Backup', 'D' => 'Admin', 'V' => 'Verify', 'R' => 'Restore',
    }
    name[c] || c
  end

  def level_name(c)
    name = {
      'F' => 'Full', 'I' => 'Incr', 'D' => 'Diff', 'O' => 'Catalog',
    }
    name[c] || c
  end

  def status_name(c)
    name = {
      'A' => 'Cancel', 'B' => 'Blocked', 'C' => 'Created',
      'D' => 'Diffs', 'R' => 'Running', 'T' => 'Okay',
      'E' => 'Error', 'e' => 'Non-fatal', 'f' => 'Fatal',
      'F' => 'FD Wait', 'M' => 'Mount Wait', 'S' => 'SD Wait',
      'c' => 'FR Wait', 'd' => 'Jmax Wait', 'j' => 'JR Wait',
      'm' => 'Media Wait', 'p' => 'Prio Wait', 's' => 'SR Wait', 
      't' => 'Start Wait',
    }
    name[c] || c
  end

  def status_style(s)
    stat = {
      'T' => 'normal', 'R' => 'okay', 'C' => 'pending',
      'A' => 'cancel', 'E' => 'error', 'f' => 'error', }
    content_tag('td', status_name(s), 'class' => stat[s] || 'oops')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bacuview-1.5 app/helpers/job_helper.rb