Class: Assistant::SeoInspectPayload

Inherits:
Object
  • Object
show all
Defined in:
app/services/assistant/seo_inspect_payload.rb

Overview

Shapes a Heatwave::Crawler::Result from :inspect mode into the JSON
payload the seo_inspect_url tool returns: technical-SEO fields, render
artifacts, and a small content preview.

Constant Summary collapse

CONTENT_PREVIEW_CHARS =

Returns max characters for the content preview.

Returns:

  • (Integer)

    max characters for the content preview

1_500
ARTIFACT_LIMIT =

Returns max artifacts of each type to include.

Returns:

  • (Integer)

    max artifacts of each type to include

10

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, result) ⇒ void

Parameters:



26
27
28
29
# File 'app/services/assistant/seo_inspect_payload.rb', line 26

def initialize(url, result)
  @url = url
  @result = result
end

Class Method Details

.call(url, result) ⇒ Hash

Returns the tool payload (nil values stripped).

Parameters:

Returns:

  • (Hash)

    the tool payload (nil values stripped)



18
19
20
# File 'app/services/assistant/seo_inspect_payload.rb', line 18

def call(url, result)
  new(url, result).call
end

Instance Method Details

#callHash

Returns the tool payload (nil values stripped).

Returns:

  • (Hash)

    the tool payload (nil values stripped)



32
33
34
35
36
37
38
39
40
# File 'app/services/assistant/seo_inspect_payload.rb', line 32

def call
  {
    url: url,
    final_url: result.final_url,
    status: result.status,
    retrieval_method: result.tier.to_s,
    redirect_chain: result.details[:redirect_chain]
  }.merge(seo_fields).merge(artifact_fields).compact
end