Class: ClockworkWeb::HomeController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/clockwork_web/home_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/clockwork_web/home_controller.rb', line 10

def index
  @events =
    Clockwork.manager.instance_variable_get(:@events).sort_by do |e|
      at = e.instance_variable_get(:@at)
      [
        e.instance_variable_get(:@period),
        (at && at.instance_variable_get(:@hour)) || -1,
        (at && at.instance_variable_get(:@min)) || -1,
        e.job.to_s
      ]
    end

  @last_runs = ClockworkWeb.last_runs
  @disabled = ClockworkWeb.disabled_jobs
  @last_heartbeat = ClockworkWeb.last_heartbeat
end

#jobObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/clockwork_web/home_controller.rb', line 27

def job
  job = params[:job]
  enable = params[:enable] == "true"
  if enable
    ClockworkWeb.enable(job)
  else
    ClockworkWeb.disable(job)
  end
  ClockworkWeb.on_job_update.call(job: job, enable: enable, user: try(:current_user)) if ClockworkWeb.on_job_update
  redirect_to root_path
end