feat: improve worker logging
- Added current time logging to the worker to help debug and analyze processing times - Cleaned up assets initializer file
This commit is contained in:
parent
936db76437
commit
2042732787
@ -19,11 +19,11 @@ class BatchGenerateWeatherArtsWorker
|
||||
|
||||
cities_to_process.each do |city|
|
||||
if within_sunrise_time?(city)
|
||||
Rails.logger.info "Generating weather art for #{city.name}"
|
||||
Rails.logger.info "Generating weather art for #{city.name} (time: [#{city.formatted_current_time(:all)}])"
|
||||
GenerateWeatherArtWorker.perform_async(city.id)
|
||||
processed_cities << city.name
|
||||
else
|
||||
Rails.logger.info "Skipping #{city.name} due to local time not being within sunrise hours."
|
||||
Rails.logger.info "Skipping #{city.name} (time: [#{city.formatted_current_time(:all)}]) due to local time not being within sunrise hours."
|
||||
skipped_cities << city.name
|
||||
end
|
||||
sleep SLEEP_DURATION
|
||||
@ -41,7 +41,7 @@ class BatchGenerateWeatherArtsWorker
|
||||
.where.not(image_attachment: nil)
|
||||
.count
|
||||
|
||||
[DAILY_GENERATION_LIMIT - today_generations, 0].max
|
||||
[ DAILY_GENERATION_LIMIT - today_generations, 0 ].max
|
||||
end
|
||||
|
||||
def print_cities_list(cities, start_time)
|
||||
@ -56,15 +56,16 @@ class BatchGenerateWeatherArtsWorker
|
||||
|
||||
def within_sunrise_time?(city)
|
||||
local_time = get_local_time(city)
|
||||
Rails.logger.info "#{city.name} now hour: #{local_time.hour}"
|
||||
local_time.hour >= 8 && local_time.hour <= 18
|
||||
end
|
||||
|
||||
def get_local_time(city)
|
||||
return Time.current unless city
|
||||
timezone_info = city.country&.timezones&.first
|
||||
timezone_info = eval(city.country.timezones).first
|
||||
return Time.current unless timezone_info
|
||||
|
||||
timezone = ActiveSupport::TimeZone["zoneName"] ||
|
||||
timezone = ActiveSupport::TimeZone[timezone_info["zoneName"]] ||
|
||||
ActiveSupport::TimeZone["UTC"]
|
||||
Time.current.in_time_zone(timezone)
|
||||
end
|
||||
|
@ -10,4 +10,3 @@ Rails.application.config.assets.version = "1.0"
|
||||
# Rails.application.config.assets.precompile += %w( *.png *.jpg *.jpeg *.gif )
|
||||
# Rails.application.config.assets.paths << Rails.root.join("app/assets/builds")
|
||||
# Rails.application.config.assets.precompile += %w( *.png *.jpg *.jpeg *.gif )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user