Class: Deepsearch::Engine::Steps::DataAggregation::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/deepsearch/engine/steps/data_aggregation/process.rb

Overview

Takes a list of website URLs from a previous search step and processes them in parallel. For each URL, it fetches, parses, and cleans the content using ‘ParsedWebsite`. It aggregates the successfully parsed websites into a `Result` object.

Constant Summary collapse

MAX_CONCURRENCY =
30

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(websites: []) ⇒ Process

Returns a new instance of Process.



20
21
22
# File 'lib/deepsearch/engine/steps/data_aggregation/process.rb', line 20

def initialize(websites: [])
  @websites = websites
end

Instance Attribute Details

#websitesObject (readonly)

Returns the value of attribute websites.



18
19
20
# File 'lib/deepsearch/engine/steps/data_aggregation/process.rb', line 18

def websites
  @websites
end

Instance Method Details

#executeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/deepsearch/engine/steps/data_aggregation/process.rb', line 24

def execute
  Deepsearch.configuration.logger.debug("Starting data aggregation for #{@websites.size} websites")

  parsed_websites = process_in_parallel
  parsed_websites.filter!(&:success?)

  Result.new(
    parsed_websites: parsed_websites
  )
rescue StandardError => e
  Result.new(
    parsed_websites: [],
    error: e.message
  )
end