Class: SourceMonitor::Fetching::FeedFetcher::EntryProcessor
- Inherits:
-
Object
- Object
- SourceMonitor::Fetching::FeedFetcher::EntryProcessor
- Defined in:
- lib/source_monitor/fetching/feed_fetcher/entry_processor.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source:) ⇒ EntryProcessor
constructor
A new instance of EntryProcessor.
- #process_feed_entries(feed) ⇒ Object
Constructor Details
#initialize(source:) ⇒ EntryProcessor
Returns a new instance of EntryProcessor.
11 12 13 |
# File 'lib/source_monitor/fetching/feed_fetcher/entry_processor.rb', line 11 def initialize(source:) @source = source end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
9 10 11 |
# File 'lib/source_monitor/fetching/feed_fetcher/entry_processor.rb', line 9 def source @source end |
Instance Method Details
#process_feed_entries(feed) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/source_monitor/fetching/feed_fetcher/entry_processor.rb', line 15 def process_feed_entries(feed) return FeedFetcher::EntryProcessingResult.new( created: 0, updated: 0, unchanged: 0, failed: 0, items: [], errors: [], created_items: [], updated_items: [] ) unless feed.respond_to?(:entries) entries = Array(feed.entries) return empty_result if entries.empty? # Pre-fetch existing items in bulk (2 SELECTs instead of N per-entry). # If the batch index build fails, fall back to per-entry lookups. existing_items_index = begin SourceMonitor::Items::BatchItemCreator.build_index(source: source, entries: entries) rescue StandardError nil end process_entries_with_index(entries, existing_items_index) end |