app/services/location_syncer.rb
# Creates or updates Locations based on the array of location-attribute
# hashes @locations.
#
# @return [Hash] results tallying zips and new, updated, and total Locations
# @example
#   LocationSyncer.call
#     => {
#             :new => 388,
#         :updated => 0,
#            :zips => [
#                       "90044",
#                       "91340",
#                       ...
#                     ],
#           :total => 405
#     }
# rubocop:disable Metrics/MethodLength
Creates or updates Locations based on the array of location-attribute
hashes @locations.
Creates or updates Locations based on the array of location - attribute hashes @locations .
def call
    results = { new: 0, updated: 0, zips: Set.new }
    results[:total] = @locations.each do |attr|
      next if attr['addr1'].blank?
      if (location = Location.find_or_init(attr)).user_facing_attributes_changed?
        results[:zips] << location.zip
        log_location_change(location: location, results: results)
      end
      location.save
    end.size
    log_results(results)
    results
  end
def call results = { new : 0 , updated : 0 , zips : Set . new } results [ :total ] = @locations . each do | attr | next if attr [ 'addr1' ] . blank? if ( location = Location . find_or_init ( attr ) ) . user_facing_attributes_changed? results [ :zips ] << location . zip log_location_change ( location : location , results : results ) end location . save end . size log_results ( results ) results end
Creates or updates Locations based on the array of location-attribute
hashes @locations.
Creates or updates Locations based on the array of location - attribute hashes @locations .
results tallying zips and new, updated, and total Locations
results tallying zips and new updated and total Locations
Hash
example
None