Class: SolidObserver::CLI::Jobs

Inherits:
Base
  • Object
show all
Defined in:
lib/solid_observer/cli/jobs.rb

Instance Method Summary collapse

Methods inherited from Base

call, #call

Instance Method Details

#discard(job_id) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/solid_observer/cli/jobs.rb', line 37

def discard(job_id)
  return error("SolidQueue is not available") unless solid_queue_available?

  job = find_failed_job(job_id)
  return unless job

  return info("Discard cancelled") unless confirm("Discard job #{job_id}? This cannot be undone.", default: false)

  job.discard
  success("✓ Job #{job_id} has been discarded")
end

#list(status: nil, queue: nil, job_class: nil, limit: 20) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/solid_observer/cli/jobs.rb', line 6

def list(status: nil, queue: nil, job_class: nil, limit: 20)
  return error("SolidQueue is not available") unless solid_queue_available?

  jobs = fetch_jobs(status: status, queue: queue, job_class: job_class, limit: limit)

  return warning("No jobs found matching the criteria") if jobs.empty?

  print_jobs_table(jobs)
end

#retry_job(job_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/solid_observer/cli/jobs.rb', line 25

def retry_job(job_id)
  return error("SolidQueue is not available") unless solid_queue_available?

  job = find_failed_job(job_id)
  return unless job

  return info("Retry cancelled") unless confirm("Retry job #{job_id}?")

  job.retry
  success("✓ Job #{job_id} has been queued for retry")
end

#show(job_id) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/solid_observer/cli/jobs.rb', line 16

def show(job_id)
  return error("SolidQueue is not available") unless solid_queue_available?

  job = find_job(job_id)
  return unless job

  print_job_details(job)
end