Class: BlogSchemaExtractor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#log_debug, #log_warning, #logger, #options, #tagged_logger

Constructor Details

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

Returns a new instance of BlogSchemaExtractor.



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

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.



2
3
4
# File 'app/services/blog_schema_extractor.rb', line 2

def article
  @article
end

#modelObject (readonly)

Returns the value of attribute model.



2
3
4
# File 'app/services/blog_schema_extractor.rb', line 2

def model
  @model
end

#resultObject (readonly)

Returns the value of attribute result.



2
3
4
# File 'app/services/blog_schema_extractor.rb', line 2

def result
  @result
end

Instance Method Details

#processObject



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

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