jobs_helper.rb 517 B

123456789101112131415161718192021
  1. module JobsHelper
  2. def status(job)
  3. case
  4. when job.failed_at
  5. content_tag :span, 'failed', class: 'label label-danger'
  6. when job.locked_at && job.locked_by
  7. content_tag :span, 'running', class: 'label label-info'
  8. else
  9. content_tag :span, 'queued', class: 'label label-warning'
  10. end
  11. end
  12. def relative_distance_of_time_in_words(time)
  13. if time < (now = Time.now)
  14. time_ago_in_words(time) + ' ago'
  15. else
  16. 'in ' + distance_of_time_in_words(time, now)
  17. end
  18. end
  19. end