Sha256: b656db0a92d543d61ff7d43cd85866cbcea9f1a706553a44e20455f057d6e3e1

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

class ScheduledTasksController < ApplicationController
  class << self
    private

    def task_column_options
      ::ScheduledTask.rake_tasks.map { |st| [st, st] }
    end
  end

  active_scaffold :scheduled_task do |conf|
    [:create, :update, :list].each do |action|
      conf.send(action).columns.exclude(:next_run, :last_fail_status, :last_run_start,
                                        :last_run_successful_start, :last_run_unsuccessful_start,
                                        :last_run_successful_end, :last_run_unsuccessful_end,
                                        :pid)
    end
    conf.columns[:task].form_ui = :select
    conf.columns[:task].options ||= {}
    conf.columns[:task].options[:options] = task_column_options
    conf.action_links.add :run_now, label: I18n.t(:run_now), type: :member,
                                    crud_type: :update, method: :put, position: false
  end

  def log
    record = find_if_allowed(params[:id], :read)
    @log_file = record.log_file(params[:identifier])
  end

  def status
  end

  def status_content
    @scheduled_tasks = ::ScheduledTask.order(task: :asc, scheduling: :asc)
    render layout: false
  end

  def run_now
    process_action_link_action do |record|
      record.update_attributes!(next_run: Time.zone.now)
      record.reload
      flash[:info] = "Next run adjusted to #{record.next_run}"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tasks_scheduler-0.3.0 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.2.3 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.2.2 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.2.1 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.2.0 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.1.0 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.0.10 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.0.9 app/controllers/scheduled_tasks_controller.rb
tasks_scheduler-0.0.8 app/controllers/scheduled_tasks_controller.rb