Class: Cosmo::Web::Controllers::Crons

Inherits:
Application show all
Defined in:
lib/cosmo/web/controllers/crons.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

#_tableObject



14
15
16
# File 'lib/cosmo/web/controllers/crons.rb', line 14

def _table
  ok render("crons/_table", { schedules: cron.all })
end

#deleteObject

Purge the schedule from NATS so it stops firing.



27
28
29
30
31
# File 'lib/cosmo/web/controllers/crons.rb', line 27

def delete
  subject = Rack::Utils.unescape(params["subject"].to_s)
  cron.delete!(subject)
  _table
end

#indexObject



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

def index
  content_for :title, "Crons"
  ok render("crons/index", layout: true)
end

#run_nowObject

Dispatch the job immediately, bypassing the schedule timer. Expects params = the schedule subject stored in NATS.



20
21
22
23
24
# File 'lib/cosmo/web/controllers/crons.rb', line 20

def run_now
  subject = Rack::Utils.unescape(params["subject"].to_s)
  cron.run_now!(subject)
  ok
end