Sha256: 99903417c548c029aaf92e11d1a4cd9c2cedd4757311093dcfd15d95c4ccf551

Contents?: true

Size: 983 Bytes

Versions: 3

Compression:

Stored size: 983 Bytes

Contents

module ClockworkWeb
  class HomeController < ActionController::Base
    layout false
    helper ClockworkWeb::HomeHelper

    http_basic_authenticate_with name: ENV["CLOCKWORK_USERNAME"], password: ENV["CLOCKWORK_PASSWORD"] if ENV["CLOCKWORK_PASSWORD"]

    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

    def job
      job = params[:job]
      if params[:enable] == "true"
        ClockworkWeb.enable(job)
      else
        ClockworkWeb.disable(job)
      end
      redirect_to root_path
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clockwork_web-0.0.5 app/controllers/clockwork_web/home_controller.rb
clockwork_web-0.0.4 app/controllers/clockwork_web/home_controller.rb
clockwork_web-0.0.3 app/controllers/clockwork_web/home_controller.rb