- Add manual task execution buttons for BatchGenerateWeatherArtsWorker, RefreshSitemapWorker, and CleanAhoyDataWorker - Improve browser blocking functionality in ApplicationController - Refactor Sidekiq jobs management to include statistics and task execution - Update various jobs to conform to new standards This feature allows for more fine-grained control over Sidekiq tasks and improves the overall user experience.
87 lines
2.8 KiB
Ruby
87 lines
2.8 KiB
Ruby
# app/admin/sidekiq_tasks.rb
|
|
ActiveAdmin.register_page "Sidekiq Tasks" do
|
|
menu label: "Sidekiq Tasks", priority: 99
|
|
|
|
content title: "Sidekiq Tasks Management" do
|
|
div class: "sidekiq-tasks" do
|
|
panel "Manual Task Execution" do
|
|
div class: "task-buttons" do
|
|
div class: "task-button" do
|
|
h3 "Batch Generate Weather Arts"
|
|
form action: admin_sidekiq_tasks_run_task_path, method: :post do
|
|
input type: "hidden", name: "authenticity_token", value: form_authenticity_token
|
|
input type: "hidden", name: "task", value: "BatchGenerateWeatherArtsWorker"
|
|
select name: "city_id" do
|
|
City.all.map do |city|
|
|
option city.name, value: city.id
|
|
end
|
|
end
|
|
input type: "submit", value: "Run Task", class: "button"
|
|
end
|
|
end
|
|
|
|
div class: "task-button" do
|
|
h3 "Refresh Sitemap"
|
|
form action: admin_sidekiq_tasks_run_task_path, method: :post do
|
|
input type: "hidden", name: "authenticity_token", value: form_authenticity_token
|
|
input type: "hidden", name: "task", value: "RefreshSitemapWorker"
|
|
input type: "submit", value: "Run Task", class: "button"
|
|
end
|
|
end
|
|
|
|
div class: "task-button" do
|
|
h3 "Clean Ahoy Data"
|
|
form action: admin_sidekiq_tasks_run_task_path, method: :post do
|
|
input type: "hidden", name: "authenticity_token", value: form_authenticity_token
|
|
input type: "hidden", name: "task", value: "CleanAhoyDataWorker"
|
|
input type: "submit", value: "Run Task", class: "button"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
panel "Sidekiq Statistics" do
|
|
stats = Sidekiq::Stats.new
|
|
table class: "sidekiq-stats" do
|
|
tr do
|
|
th "Processed Jobs"
|
|
td stats.processed
|
|
end
|
|
tr do
|
|
th "Failed Jobs"
|
|
td stats.failed
|
|
end
|
|
tr do
|
|
th "Enqueued Jobs"
|
|
td stats.enqueued
|
|
end
|
|
tr do
|
|
th "Scheduled Jobs"
|
|
td stats.scheduled_size
|
|
end
|
|
tr do
|
|
th "Retry Set Size"
|
|
td stats.retry_size
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
page_action :run_task, method: :post do
|
|
task_name = params[:task]
|
|
city_id = params[:city_id]
|
|
|
|
case task_name
|
|
when "BatchGenerateWeatherArtsWorker"
|
|
GenerateWeatherArtWorker.perform_async(city_id)
|
|
when "RefreshSitemapWorker"
|
|
RefreshSitemapWorker.perform_async
|
|
when "CleanAhoyDataWorker"
|
|
CleanAhoyDataWorker.perform_async
|
|
end
|
|
|
|
redirect_to admin_sidekiq_tasks_path, notice: "Task #{task_name} has been queued"
|
|
end
|
|
end
|