Last active
August 29, 2015 14:07
-
-
Save meetrajesh/ddc32f10b7d6481743e6 to your computer and use it in GitHub Desktop.
reindex thin elastic with custom names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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