1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

add explicit result message on rake task fablab:es_build_availabilities_index

This commit is contained in:
Sylvain 2016-10-05 12:28:13 +02:00
parent 592c250b49
commit 6487ea7e08

View File

@ -134,13 +134,21 @@ namespace :fablab do
# create doctype
client.indices.put_mapping index: Availability.index_name, type: Availability.document_type, body: Availability.mappings.to_hash
# index requested documents
if args.id
AvailabilityIndexerWorker.perform_async(:index, id)
else
Availability.pluck(:id).each do |availability_id|
AvailabilityIndexerWorker.perform_async(:index, availability_id)
# verify doctype creation was successful
if client.indices.exists_type? index: Availability.index_name, type: Availability.document_type
puts "[ElasticSearch] #{Availability.index_name}/#{Availability.document_type} successfully created with its mapping."
# index requested documents
if args.id
AvailabilityIndexerWorker.perform_async(:index, id)
else
Availability.pluck(:id).each do |availability_id|
AvailabilityIndexerWorker.perform_async(:index, availability_id)
end
end
else
puts "[ElasticSearch] An error occurred while creating #{Availability.index_name}/#{Availability.document_type}. Please check your ElasticSearch configuration."
puts "\nCancelling..."
end
end