Class: Miteru::Orchestrator
- Defined in:
- lib/miteru/orchestrator.rb
Instance Method Summary collapse
- #call ⇒ Object
- #feeds ⇒ Array<Miteru::Feeds::Base>
- #non_cached_websites ⇒ Array<Miteru::Website>
- #websites ⇒ Array<Miteru::Website>
Methods inherited from Service
Instance Method Details
#call ⇒ Object
5 6 7 8 9 |
# File 'lib/miteru/orchestrator.rb', line 5 def call logger.info("#{non_cached_websites.length} websites loaded in total.") if verbose? array_of_args = non_cached_websites.map { |website| [website.url, website.source] } Jobs::CrawleJob.perform_bulk(array_of_args, batch_size: Miteru.config.sidekiq_batch_size) end |
#feeds ⇒ Array<Miteru::Feeds::Base>
45 46 47 |
# File 'lib/miteru/orchestrator.rb', line 45 def feeds @feeds ||= Miteru.feeds.map(&:new) end |
#non_cached_websites ⇒ Array<Miteru::Website>
32 33 34 35 36 37 38 39 40 |
# File 'lib/miteru/orchestrator.rb', line 32 def non_cached_websites @non_cached_websites ||= [].tap do |out| out << if cache? websites.reject { |website| cache.cached?(website.url) } else websites end end.flatten.uniq(&:url) end |
#websites ⇒ Array<Miteru::Website>
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/miteru/orchestrator.rb', line 14 def websites @websites ||= [].tap do |out| feeds.each do |feed| result = feed.result if result.success? websites = result.value! logger.info("Feed:#{feed.source} has #{websites.length} websites.") if verbose? out << websites else logger.warn("Feed:#{feed.source} failed - #{result.failure}") end end end.flatten.uniq(&:url) end |