Module: SolidQueueDashboard::JobsHelper

Defined in:
app/helpers/solid_queue_dashboard/jobs_helper.rb

Instance Method Summary collapse

Instance Method Details

#any_jobs_filters?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/helpers/solid_queue_dashboard/jobs_helper.rb', line 53

def any_jobs_filters?
  params[:class_name].present? || params[:status].present? || params[:queue_name].present?
end

#format_failure_rate(failure_rate, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/solid_queue_dashboard/jobs_helper.rb', line 39

def format_failure_rate(failure_rate, options = {})
  badge_variant = case failure_rate
  when 0..1
    "badge-emerald"
  when 1..5
    "badge-amber"
  else
    "badge-red"
  end

  options[:class] = [ "badge", badge_variant, options[:class] ].compact_blank.join(" ")
  tag.span(number_to_percentage(failure_rate, precision: 2, strip_insignificant_zeros: true), **options)
end

#job_status_badge(status, options = {}) ⇒ Object



21
22
23
24
# File 'app/helpers/solid_queue_dashboard/jobs_helper.rb', line 21

def job_status_badge(status, options = {})
  options[:class] = [ "badge", job_status_badge_class(status), options[:class] ].compact_blank.join(" ")
  tag.span(status.to_s.titleize, **options)
end

#job_status_badge_class(status) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/solid_queue_dashboard/jobs_helper.rb', line 26

def job_status_badge_class(status)
  {
    "green": "badge-green",
    "amber": "badge-amber",
    "red": "badge-red",
    "blue": "badge-blue",
    "sky": "badge-sky",
    "zinc": "badge-zinc",
    "indigo": "badge-indigo",
    "purple": "badge-purple"
  }[Job::STATUS_COLORS[status]&.to_sym || :zinc]
end

#job_status_circle(status, options = {}) ⇒ Object



3
4
5
6
# File 'app/helpers/solid_queue_dashboard/jobs_helper.rb', line 3

def job_status_circle(status, options = {})
  options[:class] = [ "circle", job_status_circle_class(status), options[:class] ].compact_blank.join(" ")
  tag.span("", **options)
end

#job_status_circle_class(status) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/solid_queue_dashboard/jobs_helper.rb', line 8

def job_status_circle_class(status)
  {
    "green": "circle-green",
    "amber": "circle-amber",
    "red": "circle-red",
    "blue": "circle-blue",
    "sky": "circle-sky",
    "zinc": "circle-zinc",
    "indigo": "circle-indigo",
    "purple": "circle-purple"
  }[Job::STATUS_COLORS[status]&.to_sym || :zinc]
end