Class: ArticleUnpublishedHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- ArticleUnpublishedHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/article_unpublished_handler.rb
Overview
Async handler for Events::ArticleUnpublished.
Archives the SiteMap entries associated with the article so that historical
SEO data (keywords, traffic data points, embeddings) is retained but the
pages are excluded from the live sitemap XML and all operational queries.
Runs asynchronously so the CRM state transition is not delayed by DB writes.
Instance Method Summary collapse
Instance Method Details
#perform(event) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/subscribers/article_unpublished_handler.rb', line 15 def perform(event) article = Article.find_by(id: event.data[:article_id]) return unless article article.purge_edge_cache(include_indirect_associations: true) article.site_maps.update_all(state: 'archived') rescue StandardError => e ErrorReporting.error(e) raise end |