Skip to content

Instantly share code, notes, and snippets.

@meetrajesh
Last active August 29, 2015 14:07
Show Gist options
  • Save meetrajesh/ddc32f10b7d6481743e6 to your computer and use it in GitHub Desktop.
Save meetrajesh/ddc32f10b7d6481743e6 to your computer and use it in GitHub Desktop.
reindex thin elastic with custom names
# update thin merchant index with new field
include Utils::Business
ThinMerchant.elastic_scan_update do |t|
# only perform this reindex for Nevada for now
next t if t['state'] != 'NV'
tm = ThinMerchant.find_by_id(t['thin_merchant_id'])
if tm
service = Service.find(t['service_id'])
if (external_services = tm.highest_priority_external_services(service).presence) && external_services.count > 0
custom_variation_names = external_services.map(&:variation_name)
if custom_variation_names.present?
input = [t['name']] + filter_custom_variation_names(custom_variation_names)
t['completion_name'] = {
:input => input,
:output => t['name'],
:payload => "#{t['city']}, #{t['state']}"
}
end
end
end
t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment