class WeighflowCli::OrderHandler::OrderRepository
Attributes
orders[R]
Public Class Methods
new(orders = [])
click to toggle source
# File lib/weighflow_cli/order_handler.rb, line 203 def initialize(orders = []) @orders = orders end
Public Instance Methods
perform()
click to toggle source
# File lib/weighflow_cli/order_handler.rb, line 207 def perform adds = [] updates = [] unchanged = 0 deletes = [] # create file if not existing File.open(index_file_name, "w") {} unless File.exists?(index_file_name) # orders.each do |order| order_checksum = create_checksum(order) index_result = find_index(order[:external_unique_id].to_s) if index_result if index_result.checksum != order_checksum index_result.delete! # remove old, schedule update updates << order # setup update to be added to cache else unchanged += 1 end else adds << order end end # Remove and orders that will be deleted on store_in_cache deletes = find_deletes(orders) # # Store all orders in data path with indexed file store_in_cache(orders) # # # { statistics: { adds: adds.size, updates: updates.size, deletes: deletes.size, unchanged: unchanged }, adds: external_ids(adds), updates: external_ids(updates), deletes: external_ids(deletes) } end