refactor: change weather art job processing method

- Replace synchronous job processing with asynchronous
- Ensure processing does not exceed API rate limits

This change allows for better performance by offloading the
queue management to Sidekiq, enabling more efficient
parallel processing of weather art generation. It also
prevents potential API rate limit violations by maintaining
a delay between requests.
This commit is contained in:
songtianlun 2025-01-23 09:20:49 +08:00
parent 2d5521c3dc
commit c1fa16c690

View File

@ -10,7 +10,8 @@ class BatchGenerateWeatherArtsWorker
cities_to_process.each do |city|
break if Time.current - start_time > max_duration
GenerateWeatherArtJob.perform_now(city)
# GenerateWeatherArtJob.perform_now(city)
GenerateWeatherArtJob.perform_async(city)
sleep 1.minute # 确保不超过API限制
end
end