Class: ArticleLinkCheckerWorker

Inherits:
Object
  • Object
show all
Includes:
RouteUrlHelpers, Sidekiq::Job, Workers::StatusBroadcastable
Defined in:
app/workers/article_link_checker_worker.rb

Overview

Processes link checks for articles. Supports two modes:

Legacy mode (default when called with link hrefs or no args):
Processes pending LinkCheck records for external links.

Audit mode (called with article_ids: [...]):
Runs the unified ArticleLinkAuditor on specific articles,
persisting results and updating the editorial link graph.
Supports job status tracking with redirect_to for the CRM UI.

Constant Summary

Constants included from RouteUrlHelpers

RouteUrlHelpers::ROUTES

Instance Attribute Summary

Attributes included from Workers::StatusBroadcastable

#broadcast_status_updates

Instance Method Summary collapse

Methods included from Workers::StatusBroadcastable::Overrides

#at, #store, #total

Instance Method Details

#perform(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    job options (non-Hash values are treated as {})

Options Hash (options):

  • article_ids (Array<Integer>)

    article IDs to run the unified audit on (audit mode)

  • links (Array<String>)

    external link hrefs to check (legacy mode)

  • skip_external (Boolean)

    skip checking external links in audit mode (default true)

  • return_path (String)

    path to redirect to when the job completes



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/article_link_checker_worker.rb', line 25

def perform(options = {})
  # Guard, not normalization: LinkCheck#replace_links enqueues an ARRAY of new
  # links (app/models/link_check.rb), so `options` is not always a Hash. Key
  # spelling itself is handled by Sidekiq::NormalizeArgsMiddleware::Server.
  options = {} unless options.is_a?(Hash)

  if options[:article_ids]
    run_article_audit(options[:article_ids], options)
  else
    run_legacy_check(options)
  end
end