Class: Item::SynchronizeRefurbSpecs

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

Overview

Synchronizes item description, pricing and cogs to the refurbished version of
these items

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#process(base_scope: nil, limit: nil) ⇒ Object

Process refurished item, optionally specify:
a base_scope to use, e.g Item.controls
a limit to the number of records to process



9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/item/synchronize_refurb_specs.rb', line 9

def process(base_scope: nil, limit: nil)
  base_scope ||= Item.all
  base_scope = base_scope.condition_refurbished.where.not(new_item_id: nil)
  base_scope = base_scope.limit(limit) if limit
  result_messages = []
  Item.transaction do
    base_scope.find_each { |item| result_messages << propagate_specs(item) }
  end
  logger.info "SynchronizeRefurbSpecs results: #{result_messages.join(', ')}"
  result_messages
end