From b05cf10017b9735a020c5d89b17ceb567edc15dd Mon Sep 17 00:00:00 2001 From: songtianlun Date: Fri, 24 Jan 2025 00:14:29 +0800 Subject: [PATCH] refactor: simplify city weather generation logic - Introduced constants for configuration settings such as generation interval, maximum duration, and sleep duration. - Updated the `perform` method to utilize these constants for better readability and maintainability. - Refactored the `perform` method in `GenerateWeatherArtWorker` to improve flow and error handling by creating separate methods for fetching weather data, generating prompts, images, and handling database transactions. - Cleaned up city seeding data by removing unnecessary fields while maintaining required functionality. These changes improve the overall readability of the code and make it easier to adjust the behavior of the workers in the future without digging through the logic. --- .../batch_generate_weather_arts_worker.rb | 27 ++++-- app/workers/generate_weather_art_worker.rb | 79 ++++++++++------ db/seeds/cities/australia.rb | 8 +- db/seeds/cities/bangladesh.rb | 4 +- db/seeds/cities/brazil.rb | 4 +- db/seeds/cities/canada.rb | 4 +- db/seeds/cities/china.rb | 92 ++----------------- db/seeds/cities/egypt.rb | 4 +- db/seeds/cities/france.rb | 4 +- db/seeds/cities/germany.rb | 8 +- db/seeds/cities/india.rb | 8 +- db/seeds/cities/japan.rb | 8 +- db/seeds/cities/mexico.rb | 4 +- db/seeds/cities/nigeria.rb | 4 +- db/seeds/cities/pakistan.rb | 4 +- db/seeds/cities/russia.rb | 8 +- db/seeds/cities/saudi_arabia.rb | 4 +- db/seeds/cities/singapore.rb | 4 +- db/seeds/cities/south_korea.rb | 4 +- db/seeds/cities/thailand.rb | 4 +- db/seeds/cities/turkey.rb | 8 +- db/seeds/cities/uk.rb | 4 +- db/seeds/cities/usa.rb | 16 +--- db/seeds/cities/vietnam.rb | 8 +- 24 files changed, 106 insertions(+), 216 deletions(-) diff --git a/app/workers/batch_generate_weather_arts_worker.rb b/app/workers/batch_generate_weather_arts_worker.rb index 95948d2..f3edd7b 100644 --- a/app/workers/batch_generate_weather_arts_worker.rb +++ b/app/workers/batch_generate_weather_arts_worker.rb @@ -1,28 +1,35 @@ class BatchGenerateWeatherArtsWorker include Sidekiq::Worker + GENERATION_INTERVAL = 6.hours + MAX_DURATION = 50.minutes + SLEEP_DURATION = 3.seconds + def perform(*args) start_time = Time.current - max_duration = 50.minutes cities_to_process = get_eligible_cities cities_to_process.each do |city| - break if Time.current - start_time > max_duration + break if Time.current - start_time > MAX_DURATION - # GenerateWeatherArtJob.perform_now(city) GenerateWeatherArtWorker.perform_async(city.id) - sleep 3.seconds + sleep SLEEP_DURATION end end private def get_eligible_cities - City.active - .where(active: true) - .where("last_weather_fetch IS NULL OR last_weather_fetch < ?", Date.today) - # .select { |city| early_morning_in_timezone?(city.timezone) } - end + cutoff_time = Time.current - GENERATION_INTERVAL -end + City.active + .joins("LEFT JOIN ( + SELECT city_id, MAX(created_at) as last_generation_time + FROM weather_arts + GROUP BY city_id + ) latest_arts ON cities.id = latest_arts.city_id") + .where("latest_arts.last_generation_time IS NULL OR latest_arts.last_generation_time < ?", cutoff_time) + .order(:priority) + end +end \ No newline at end of file diff --git a/app/workers/generate_weather_art_worker.rb b/app/workers/generate_weather_art_worker.rb index 6d0c622..0f8a912 100644 --- a/app/workers/generate_weather_art_worker.rb +++ b/app/workers/generate_weather_art_worker.rb @@ -1,45 +1,66 @@ class GenerateWeatherArtWorker include Sidekiq::Worker - def perform(*args) - city_id = args[0] - return if city.last_weather_fetch&.today? + def perform(city_id) + @city = City.find(city_id) - weather_service = WeatherService.new - ai_service = AiService.new - - # 获取天气数据 - weather_data = weather_service.get_weather(city.latitude, city.longitude) + weather_data = fetch_weather_data return unless weather_data - # 生成提示词 - prompt = ai_service.generate_prompt(city, weather_data) + prompt = generate_prompt(weather_data) return unless prompt - # 生成图像 - image_url = ai_service.generate_image(prompt) + image_url = generate_image(prompt) return unless image_url - # 创建天气艺术记录 - weather_art = city.weather_arts.create!( - weather_date: Date.today, - **weather_data, - prompt: prompt - ) + create_weather_art(weather_data, prompt, image_url) + rescue StandardError => e + Rails.logger.error "Error generating weather art for city #{city_id}: #{e.message}" + Rails.logger.error e.backtrace.join("\n") + end - # 下载并附加图像 + private + + attr_reader :city + + def fetch_weather_data + WeatherService.new.get_weather(city.latitude, city.longitude) + end + + def generate_prompt(weather_data) + AiService.new.generate_prompt(city, weather_data) + end + + def generate_image(prompt) + AiService.new.generate_image(prompt) + end + + def create_weather_art(weather_data, prompt, image_url) + ActiveRecord::Base.transaction do + weather_art = city.weather_arts.create!( + weather_date: Date.today, + prompt: prompt, + **weather_data + ) + + attach_image(weather_art, image_url) + weather_art + end + end + + def attach_image(weather_art, image_url) tempfile = Down.download(image_url) weather_art.image.attach( io: tempfile, - filename: "#{city.country.name}-#{city.name.parameterize}-#{Time.current.strftime('%Y%m%d-%H%M%S')}.png" + filename: generate_filename, + content_type: "image/png" ) - - # 更新城市状态 - city.update!( - last_weather_fetch: Time.current, - last_image_generation: Time.current - ) - rescue => e - Rails.logger.error "Error generating weather art for #{city.name}: #{e.message}" + ensure + tempfile&.close + tempfile&.unlink end -end + + def generate_filename + "#{city.country.name}-#{city.name.parameterize}-#{Time.current.strftime('%Y%m%d-%H%M%S')}.png" + end +end \ No newline at end of file diff --git a/db/seeds/cities/australia.rb b/db/seeds/cities/australia.rb index a0bcf3c..7c1939c 100644 --- a/db/seeds/cities/australia.rb +++ b/db/seeds/cities/australia.rb @@ -8,9 +8,7 @@ City.create!([ country: australia, timezone: 'Australia/Sydney', active: true, - priority: 80, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 80 }, { name: 'Melbourne', @@ -19,8 +17,6 @@ City.create!([ country: australia, timezone: 'Australia/Melbourne', active: true, - priority: 75, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 75 } ]) diff --git a/db/seeds/cities/bangladesh.rb b/db/seeds/cities/bangladesh.rb index 04bf214..a69854c 100644 --- a/db/seeds/cities/bangladesh.rb +++ b/db/seeds/cities/bangladesh.rb @@ -8,8 +8,6 @@ City.create!([ country: bangladesh, timezone: 'Asia/Dhaka', active: true, - priority: 85, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 85 } ]) diff --git a/db/seeds/cities/brazil.rb b/db/seeds/cities/brazil.rb index 02f900c..9afa326 100644 --- a/db/seeds/cities/brazil.rb +++ b/db/seeds/cities/brazil.rb @@ -8,8 +8,6 @@ City.create!([ country: brazil, timezone: 'America/Sao_Paulo', active: true, - priority: 80, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 80 } ]) diff --git a/db/seeds/cities/canada.rb b/db/seeds/cities/canada.rb index 83299cb..a2a5db4 100644 --- a/db/seeds/cities/canada.rb +++ b/db/seeds/cities/canada.rb @@ -6,7 +6,5 @@ City.create!( priority: 50, country: canada, timezone: 'America/Toronto', - active: true, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + active: true ) diff --git a/db/seeds/cities/china.rb b/db/seeds/cities/china.rb index 2e7af4c..e702e07 100644 --- a/db/seeds/cities/china.rb +++ b/db/seeds/cities/china.rb @@ -8,9 +8,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Beijing', @@ -19,9 +17,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Shenzhen', @@ -30,9 +26,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Guangzhou', @@ -41,9 +35,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Chengdu', @@ -52,9 +44,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Tianjin', @@ -63,9 +53,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Wuhan', @@ -74,9 +62,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Dongguan', @@ -85,9 +71,7 @@ City.create!([ country: china, timezone: 'Asia/Shanghai', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Chongqing', @@ -97,8 +81,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: "Xi'an", @@ -108,8 +90,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Hangzhou', @@ -119,8 +99,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Foshan', @@ -130,8 +108,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Nanjing', @@ -141,8 +117,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Hong Kong', @@ -152,8 +126,6 @@ City.create!([ timezone: 'Asia/Hong_Kong', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Shenyang', @@ -163,8 +135,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Zhengzhou', @@ -174,8 +144,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Qingdao', @@ -185,8 +153,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Suzhou', @@ -196,8 +162,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Changsha', @@ -207,8 +171,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Jinan', @@ -218,8 +180,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Kunming', @@ -229,8 +189,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Harbin', @@ -240,8 +198,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Shijiazhuang', @@ -251,8 +207,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Hefei', @@ -262,8 +216,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Dalian', @@ -273,8 +225,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Xiamen', @@ -284,8 +234,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Nanning', @@ -295,8 +243,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Changchun', @@ -306,8 +252,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Taiyuan', @@ -317,8 +261,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'New Taipei City', @@ -328,8 +270,6 @@ City.create!([ timezone: 'Asia/Taipei', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Guiyang', @@ -339,8 +279,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Wuxi', @@ -350,8 +288,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Shantou', @@ -361,8 +297,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Ürümqi', @@ -372,8 +306,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Zhongshan', @@ -383,8 +315,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Ningbo', @@ -394,8 +324,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Fuzhou', @@ -405,8 +333,6 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago }, { name: 'Nanchang', @@ -416,7 +342,5 @@ City.create!([ timezone: 'Asia/Shanghai', active: true, priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago } ]) diff --git a/db/seeds/cities/egypt.rb b/db/seeds/cities/egypt.rb index 9c19fa3..5cbc23e 100644 --- a/db/seeds/cities/egypt.rb +++ b/db/seeds/cities/egypt.rb @@ -8,8 +8,6 @@ City.create!([ country: egypt, timezone: 'Africa/Cairo', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/france.rb b/db/seeds/cities/france.rb index a831dba..ccedd84 100644 --- a/db/seeds/cities/france.rb +++ b/db/seeds/cities/france.rb @@ -8,8 +8,6 @@ City.create!([ country: france, timezone: 'Europe/Paris', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/germany.rb b/db/seeds/cities/germany.rb index 6ed3c23..3e939f0 100644 --- a/db/seeds/cities/germany.rb +++ b/db/seeds/cities/germany.rb @@ -8,9 +8,7 @@ City.create!([ country: germany, timezone: 'Europe/Berlin', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Berlin', @@ -19,8 +17,6 @@ City.create!([ country: germany, timezone: 'Europe/Berlin', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/india.rb b/db/seeds/cities/india.rb index 6794c2d..2517865 100644 --- a/db/seeds/cities/india.rb +++ b/db/seeds/cities/india.rb @@ -8,9 +8,7 @@ City.create!([ country: india, timezone: 'Asia/Kolkata', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Bengaluru', @@ -19,8 +17,6 @@ City.create!([ country: india, timezone: 'Asia/Kolkata', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/japan.rb b/db/seeds/cities/japan.rb index 9b89dfd..d29613e 100644 --- a/db/seeds/cities/japan.rb +++ b/db/seeds/cities/japan.rb @@ -8,9 +8,7 @@ City.create!([ country: japan, timezone: 'Asia/Tokyo', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Yokohama', @@ -19,8 +17,6 @@ City.create!([ country: japan, timezone: 'Asia/Tokyo', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/mexico.rb b/db/seeds/cities/mexico.rb index 4c6a957..31295aa 100644 --- a/db/seeds/cities/mexico.rb +++ b/db/seeds/cities/mexico.rb @@ -8,8 +8,6 @@ City.create!([ country: mexico, timezone: 'America/Mexico_City', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/nigeria.rb b/db/seeds/cities/nigeria.rb index c2e26bc..b6b5025 100644 --- a/db/seeds/cities/nigeria.rb +++ b/db/seeds/cities/nigeria.rb @@ -8,8 +8,6 @@ City.create!([ country: nigeria, timezone: 'Africa/Lagos', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/pakistan.rb b/db/seeds/cities/pakistan.rb index 514b3e8..fe2f944 100644 --- a/db/seeds/cities/pakistan.rb +++ b/db/seeds/cities/pakistan.rb @@ -8,8 +8,6 @@ City.create!([ country: pakistan, timezone: 'Asia/Karachi', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/russia.rb b/db/seeds/cities/russia.rb index 67367bb..937c2b0 100644 --- a/db/seeds/cities/russia.rb +++ b/db/seeds/cities/russia.rb @@ -8,9 +8,7 @@ City.create!([ country: russia, timezone: 'Europe/Moscow', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Sankt Petersburg', @@ -19,8 +17,6 @@ City.create!([ country: russia, timezone: 'Europe/Moscow', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/saudi_arabia.rb b/db/seeds/cities/saudi_arabia.rb index ce2ac9d..92f7b14 100644 --- a/db/seeds/cities/saudi_arabia.rb +++ b/db/seeds/cities/saudi_arabia.rb @@ -8,8 +8,6 @@ City.create!([ country: saudi_arabia, timezone: 'Asia/Riyadh', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/singapore.rb b/db/seeds/cities/singapore.rb index 69ff90c..89bd55a 100644 --- a/db/seeds/cities/singapore.rb +++ b/db/seeds/cities/singapore.rb @@ -8,8 +8,6 @@ City.create!([ country: singapore, timezone: 'Asia/Singapore', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/south_korea.rb b/db/seeds/cities/south_korea.rb index 04bd9cb..949df75 100644 --- a/db/seeds/cities/south_korea.rb +++ b/db/seeds/cities/south_korea.rb @@ -8,8 +8,6 @@ City.create!([ country: south_korea, timezone: 'Asia/Seoul', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/thailand.rb b/db/seeds/cities/thailand.rb index 5b8f943..a080338 100644 --- a/db/seeds/cities/thailand.rb +++ b/db/seeds/cities/thailand.rb @@ -8,8 +8,6 @@ City.create!([ country: thailand, timezone: 'Asia/Bangkok', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/turkey.rb b/db/seeds/cities/turkey.rb index d9af234..7632978 100644 --- a/db/seeds/cities/turkey.rb +++ b/db/seeds/cities/turkey.rb @@ -8,9 +8,7 @@ City.create!([ country: turkey, timezone: 'Europe/Istanbul', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Ankara', @@ -19,8 +17,6 @@ City.create!([ country: turkey, timezone: 'Europe/Istanbul', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/uk.rb b/db/seeds/cities/uk.rb index 6794ee3..8bcc574 100644 --- a/db/seeds/cities/uk.rb +++ b/db/seeds/cities/uk.rb @@ -8,8 +8,6 @@ City.create!([ country: uk, timezone: 'Europe/London', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/usa.rb b/db/seeds/cities/usa.rb index 60678fd..f0764ac 100644 --- a/db/seeds/cities/usa.rb +++ b/db/seeds/cities/usa.rb @@ -8,9 +8,7 @@ City.create!([ country: usa, timezone: 'America/Los_Angeles', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Chicago', @@ -19,9 +17,7 @@ City.create!([ country: usa, timezone: 'America/Chicago', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'New York City', @@ -30,9 +26,7 @@ City.create!([ country: usa, timezone: 'America/New_York', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Los Angeles', @@ -41,8 +35,6 @@ City.create!([ country: usa, timezone: 'America/Los_Angeles', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ]) diff --git a/db/seeds/cities/vietnam.rb b/db/seeds/cities/vietnam.rb index da6cfbe..058cc91 100644 --- a/db/seeds/cities/vietnam.rb +++ b/db/seeds/cities/vietnam.rb @@ -8,9 +8,7 @@ City.create!([ country: vietnam, timezone: 'Asia/Ho_Chi_Minh', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 }, { name: 'Hanoi', @@ -19,8 +17,6 @@ City.create!([ country: vietnam, timezone: 'Asia/Ho_Chi_Minh', active: true, - priority: 100, - last_weather_fetch: 10.days.ago, - last_image_generation: 10.days.ago + priority: 100 } ])