Class: PostSitemapRecrawlHandler

Inherits:
ApplicationJob show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/post_sitemap_recrawl_handler.rb

Overview

Async handler for Events::PostContentUpdated.

Recrawls the post's SiteMap entries (one per locale) to refresh extracted
content, rendered schema, and the internal link graph. This ensures the
sitemap analysis reflects the latest blog content shortly after an edit.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/subscribers/post_sitemap_recrawl_handler.rb', line 13

def perform(event)
  post = Post.find_by(id: event.data[:post_id])
  return unless post

  site_maps = SiteMap.where(resource_type: 'Article', resource_id: post.id)
  return unless site_maps.exists?

  crawler = Cache::SiteCrawler.new
  site_maps.find_each do |site_map|
    crawler.process(pages: SiteMap.where(id: site_map.id), extract_content: true)
  end
rescue StandardError => e
  ErrorReporting.error(e)
  raise
end