Class: BlogSchemaExtractor

Inherits:
BaseService show all
Defined in:
app/services/blog_schema_extractor.rb

Overview

Service object: blog schema extractor.

Instance Attribute Summary collapse

Attributes inherited from BaseService

#options

Instance Method Summary collapse

Methods inherited from BaseService

#log_debug, #log_warning, #logger, #tagged_logger

Constructor Details

#initialize(article, options = {}) ⇒ BlogSchemaExtractor

Returns a new instance of BlogSchemaExtractor.



6
7
8
9
10
# File 'app/services/blog_schema_extractor.rb', line 6

def initialize(article, options = {})
  @article = article
  @model = options[:model].presence || AiModelConstants.id(:blog_extraction)
  super(options)
end

Instance Attribute Details

#articleObject (readonly)

Returns the value of attribute article.



4
5
6
# File 'app/services/blog_schema_extractor.rb', line 4

def article
  @article
end

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'app/services/blog_schema_extractor.rb', line 4

def model
  @model
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'app/services/blog_schema_extractor.rb', line 4

def result
  @result
end

Instance Method Details

#processObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/blog_schema_extractor.rb', line 12

def process
  log_info "Processing schema extraction for article #{article.id}: #{article.subject}"

  @result = extract_schema_content
  save_schema_markup if @result[:schemas].present?

  # Always update the timestamp to mark that extraction was attempted
  # This prevents the same articles from being processed repeatedly
  update_extraction_timestamp

  @result
end