Class: RailsNexus::CronJobsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsNexus::CronJobsController
- Defined in:
- app/controllers/rails_nexus/cron_jobs_controller.rb
Instance Method Summary collapse
Instance Method Details
#clear_old ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/rails_nexus/cron_jobs_controller.rb', line 37 def clear_old days = params[:days].to_i CronJob.where("created_at < ?", days.days.ago).delete_all redirect_to cron_jobs_path, notice: "Deleted cron jobs older than #{days} days." end |
#destroy ⇒ Object
32 33 34 35 |
# File 'app/controllers/rails_nexus/cron_jobs_controller.rb', line 32 def destroy @cron_job.destroy redirect_to cron_jobs_path, notice: "Cron job run deleted." end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/rails_nexus/cron_jobs_controller.rb', line 7 def index @stats = CronJob.summary cron_jobs = CronJob.recent if params[:status].present? cron_jobs = cron_jobs.by_status(params[:status]) end if params[:name].present? cron_jobs = cron_jobs.where(name: params[:name]) end if params[:date_range].present? days = params[:date_range].to_i cron_jobs = cron_jobs.where("created_at >= ?", days.days.ago) end requested_size = params[:per_page].to_i page_size = requested_size.between?(1, 100) ? requested_size : 30 @pagy, @cron_jobs = pagy(cron_jobs, items: page_size) end |
#retry_job ⇒ Object
43 44 45 46 47 |
# File 'app/controllers/rails_nexus/cron_jobs_controller.rb', line 43 def retry_job cron_job = CronJob.find(params[:id]) # Re-run the job (implementation depends on job scheduler) redirect_to cron_jobs_path, notice: "Retrying job: #{cron_job.name}" end |
#show ⇒ Object
29 30 |
# File 'app/controllers/rails_nexus/cron_jobs_controller.rb', line 29 def show end |