refactor: rename workers to jobs
- Change class names from Worker to Job for better alignment with Rails convention. - Includes changes in BatchGenerateWeatherArtsJob, CleanAhoyDataJob, GenerateWeatherArtJob, and RefreshSitemapJob classes. This refactoring improves the clarity and consistency of the codebase by adhering to established naming conventions, making it easier for new developers to understand the role of these classes within the application.
This commit is contained in:
parent
ce5d09b621
commit
bf2ff282bb
@ -1,5 +1,6 @@
|
||||
class BatchGenerateWeatherArtsWorker
|
||||
include Sidekiq::Worker
|
||||
# app/jobs/batch_generate_weather_arts_job.rb
|
||||
class BatchGenerateWeatherArtsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
GENERATION_INTERVAL = 24.hours
|
||||
MAX_DURATION = 50.minutes
|
||||
@ -14,7 +15,7 @@ class BatchGenerateWeatherArtsWorker
|
||||
break if Time.current - start_time > MAX_DURATION
|
||||
Rails.logger.info "Generating weather art for #{city.name}"
|
||||
|
||||
GenerateWeatherArtWorker.perform_async(city.id)
|
||||
GenerateWeatherArtJob.perform_later(city.id)
|
||||
sleep SLEEP_DURATION
|
||||
end
|
||||
end
|
||||
@ -33,4 +34,4 @@ class BatchGenerateWeatherArtsWorker
|
||||
.where("latest_arts.last_generation_time IS NULL OR latest_arts.last_generation_time < ?", cutoff_time)
|
||||
.order(:priority)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,8 +1,6 @@
|
||||
# app/workers/clean_ahoy_data_worker.rb
|
||||
class CleanAhoyDataWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: :default, retry: false
|
||||
# app/jobs/clean_ahoy_data_job.rb
|
||||
class CleanAhoyDataJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
cleanup_old_events
|
||||
@ -29,4 +27,4 @@ class CleanAhoyDataWorker
|
||||
Rails.logger.info "Remaining events: #{Ahoy::Event.count}"
|
||||
Rails.logger.info "Remaining visits: #{Ahoy::Visit.count}"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
class GenerateWeatherArtWorker
|
||||
include Sidekiq::Worker
|
||||
class GenerateWeatherArtJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(city_id)
|
||||
@city = City.find(city_id)
|
||||
|
@ -1,5 +1,5 @@
|
||||
class RefreshSitemapWorker
|
||||
include Sidekiq::Worker
|
||||
class RefreshSitemapJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
|
||||
|
Loading…
Reference in New Issue
Block a user