Class: Cosmo::Web::Controllers::Jobs

Inherits:
Application show all
Defined in:
lib/cosmo/web/controllers/jobs.rb

Constant Summary

Constants included from Renderer

Renderer::ASSETS_ROOT, Renderer::VIEWS_ROOT

Instance Method Summary collapse

Methods inherited from Application

#content_for, #hx_request?, #initialize, #params, #path, #render

Methods included from Renderer

#no_content, #not_found, #ok, #redirect_to, #serve, #url_for

Constructor Details

This class inherits a constructor from Cosmo::Web::Controllers::Application

Instance Method Details

#_busyObject



69
70
71
72
73
# File 'lib/cosmo/web/controllers/jobs.rb', line 69

def _busy
  limit = (limit || 25).to_i
  jobs  = API::Busy.instance.list(limit:)
  ok render("jobs/_busy", { jobs: jobs, total: API::Busy.instance.size })
end

#_deadObject



63
64
65
66
67
# File 'lib/cosmo/web/controllers/jobs.rb', line 63

def _dead
  stream = API::Stream.new("dead")
  jobs = stream.messages(page: params["page"], limit: params["limit"])
  ok render("jobs/_dead", { jobs: jobs, total: stream.total })
end

#_enqueuedObject



75
76
77
78
79
80
81
# File 'lib/cosmo/web/controllers/jobs.rb', line 75

def _enqueued
  stream_name, stream_names = streams
  stream = API::Stream.new(stream_name)
  jobs = stream.messages(page: params["page"], limit: params["limit"])

  ok render("jobs/_enqueued", { jobs:, total: stream.total, stream_name:, stream_names: })
end

#_scheduledObject



57
58
59
60
61
# File 'lib/cosmo/web/controllers/jobs.rb', line 57

def _scheduled
  stream = API::Stream.new("scheduled")
  jobs = stream.messages(page: params["page"], limit: params["limit"])
  ok render("jobs/_scheduled", { jobs: jobs, total: stream.total })
end

#_statsObject



83
84
85
# File 'lib/cosmo/web/controllers/jobs.rb', line 83

def _stats
  ok render("jobs/_stats", API::Stats.summary)
end

#busyObject



14
15
16
17
18
19
# File 'lib/cosmo/web/controllers/jobs.rb', line 14

def busy
  return _busy if hx_request?

  content_for :title, "Busy Jobs"
  ok render("jobs/busy", layout: true)
end

#deadObject



36
37
38
39
40
41
# File 'lib/cosmo/web/controllers/jobs.rb', line 36

def dead
  return _dead if hx_request?

  content_for :title, "Dead Jobs"
  ok render("jobs/dead", layout: true)
end

#deleteObject



50
51
52
53
54
55
# File 'lib/cosmo/web/controllers/jobs.rb', line 50

def delete
  seq = path.split("/").last.to_i
  stream = API::Stream.new("dead")
  stream.delete(seq)
  ok
end

#enqueuedObject



21
22
23
24
25
26
27
# File 'lib/cosmo/web/controllers/jobs.rb', line 21

def enqueued
  return _enqueued if hx_request?

  content_for :title, "Enqueued Jobs"
  stream_name, _stream_names = streams
  ok render("jobs/enqueued", { stream_name: }, layout: true)
end

#indexObject



9
10
11
12
# File 'lib/cosmo/web/controllers/jobs.rb', line 9

def index
  content_for :title, "Jobs"
  ok render("jobs/index", layout: true)
end

#retryObject



43
44
45
46
47
48
# File 'lib/cosmo/web/controllers/jobs.rb', line 43

def retry
  seq = path.split("/").last.to_i
  stream = API::Stream.new("dead")
  stream.retry(seq)
  ok
end

#scheduledObject



29
30
31
32
33
34
# File 'lib/cosmo/web/controllers/jobs.rb', line 29

def scheduled
  return _scheduled if hx_request?

  content_for :title, "Scheduled Jobs"
  ok render("jobs/scheduled", layout: true)
end