2024-07-09 14:28:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Settings::BackgroundJobsController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
2024-07-16 16:26:16 -04:00
|
|
|
before_action :authenticate_admin!
|
2024-07-09 14:28:59 -04:00
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@queues = Sidekiq::Queue.all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
2024-07-09 17:50:19 -04:00
|
|
|
EnqueueReverseGeocodingJob.perform_later(params[:job_name], current_user.id)
|
|
|
|
|
|
|
|
|
|
flash.now[:notice] = 'Job was successfully created.'
|
|
|
|
|
|
|
|
|
|
redirect_to settings_background_jobs_path, notice: 'Job was successfully created.'
|
2024-07-09 14:28:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
2024-07-09 17:50:19 -04:00
|
|
|
# Clear all jobs in the queue, params[:id] contains queue name
|
|
|
|
|
queue = Sidekiq::Queue.new(params[:id])
|
|
|
|
|
|
|
|
|
|
queue.clear
|
|
|
|
|
|
|
|
|
|
flash.now[:notice] = 'Queue was successfully cleared.'
|
|
|
|
|
redirect_to settings_background_jobs_path, notice: 'Queue was successfully cleared.'
|
2024-07-09 14:28:59 -04:00
|
|
|
end
|
|
|
|
|
end
|