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
|
# app/jobs/batch_generate_weather_arts_job.rb
|
||||||
include Sidekiq::Worker
|
class BatchGenerateWeatherArtsJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
GENERATION_INTERVAL = 24.hours
|
GENERATION_INTERVAL = 24.hours
|
||||||
MAX_DURATION = 50.minutes
|
MAX_DURATION = 50.minutes
|
||||||
@ -14,7 +15,7 @@ class BatchGenerateWeatherArtsWorker
|
|||||||
break if Time.current - start_time > MAX_DURATION
|
break if Time.current - start_time > MAX_DURATION
|
||||||
Rails.logger.info "Generating weather art for #{city.name}"
|
Rails.logger.info "Generating weather art for #{city.name}"
|
||||||
|
|
||||||
GenerateWeatherArtWorker.perform_async(city.id)
|
GenerateWeatherArtJob.perform_later(city.id)
|
||||||
sleep SLEEP_DURATION
|
sleep SLEEP_DURATION
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
# app/workers/clean_ahoy_data_worker.rb
|
# app/jobs/clean_ahoy_data_job.rb
|
||||||
class CleanAhoyDataWorker
|
class CleanAhoyDataJob < ApplicationJob
|
||||||
include Sidekiq::Worker
|
queue_as :default
|
||||||
|
|
||||||
sidekiq_options queue: :default, retry: false
|
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
cleanup_old_events
|
cleanup_old_events
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class GenerateWeatherArtWorker
|
class GenerateWeatherArtJob < ApplicationJob
|
||||||
include Sidekiq::Worker
|
queue_as :default
|
||||||
|
|
||||||
def perform(city_id)
|
def perform(city_id)
|
||||||
@city = City.find(city_id)
|
@city = City.find(city_id)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class RefreshSitemapWorker
|
class RefreshSitemapJob < ApplicationJob
|
||||||
include Sidekiq::Worker
|
queue_as :default
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
|
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
|
||||||
|
Loading…
Reference in New Issue
Block a user