diff --git a/app/workers/submit_to_indexnow_worker.rb b/app/workers/submit_to_indexnow_worker.rb index 5058866..d93dd67 100644 --- a/app/workers/submit_to_indexnow_worker.rb +++ b/app/workers/submit_to_indexnow_worker.rb @@ -28,7 +28,7 @@ class SubmitToIndexnowWorker Rails.application.routes.default_url_options[:host] = @host # 收集所有需要提交的 URLs - urls = collect_urls + urls = collect_urls(recently_updated) # 分批提交 URLs (每批最多 10000 个 URLs,符合 IndexNow 限制) urls.each_slice(100) do |url_batch| @@ -50,7 +50,7 @@ class SubmitToIndexnowWorker private - def collect_urls + def collect_urls(recently_updated) urls = [] available_locales = I18n.available_locales @@ -73,7 +73,8 @@ class SubmitToIndexnowWorker end # 城市详情页 - City.find_each do |city| + City.where("updated_at > ?", recently_updated).find_each do |city| + # City.find_each do |city| urls << "#{@host}/cities/#{city.id}" available_locales.each do |locale| urls << "#{@host}/#{locale}/cities/#{city.id}" @@ -81,7 +82,8 @@ class SubmitToIndexnowWorker end # 天气艺术作品页 - WeatherArt.includes(:city).find_each do |art| + WeatherArt.includes(:city).where("updated_at > ?", recently_updated).find_each do |art| + # WeatherArt.includes(:city).find_each do |art| if art.image.attached? urls << "#{@host}/cities/#{art.city.id}/weather_arts/#{art.id}" available_locales.each do |locale|