From d0837706b6cd27f860d994bf5a2f02e1bcb9c54a Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 5 Sep 2016 15:30:46 +0200 Subject: [PATCH] fixed rake tasks --- app/workers/availability_indexer_worker.rb | 8 ++++---- app/workers/project_indexer_worker.rb | 4 ++-- lib/tasks/fablab.rake | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/workers/availability_indexer_worker.rb b/app/workers/availability_indexer_worker.rb index 622dad119..d31b95353 100644 --- a/app/workers/availability_indexer_worker.rb +++ b/app/workers/availability_indexer_worker.rb @@ -2,8 +2,8 @@ class AvailabilityIndexerWorker include Sidekiq::Worker sidekiq_options queue: 'elasticsearch', retry: true - logger = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil - client = Elasticsearch::Model.client + Logger = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil + Client = Elasticsearch::Model.client def perform(operation, record_id) logger.debug [operation, "ID: #{record_id}"] @@ -11,10 +11,10 @@ class AvailabilityIndexerWorker case operation.to_s when /index/ record = Availability.find(record_id) - client.index index: Availability.index_name, type: Availability.document_type, id: record.id, body: record.as_indexed_json + Client.index index: Availability.index_name, type: Availability.document_type, id: record.id, body: record.to_json #puts record.as_indexed_json when /delete/ - client.delete index: 'fablab', type: 'projects', id: record_id + Client.delete index: Availability.index_name, type: Availability.document_type, id: record_id else raise ArgumentError, "Unknown operation '#{operation}'" end end diff --git a/app/workers/project_indexer_worker.rb b/app/workers/project_indexer_worker.rb index 740184e0e..7dce4fa47 100644 --- a/app/workers/project_indexer_worker.rb +++ b/app/workers/project_indexer_worker.rb @@ -11,9 +11,9 @@ class ProjectIndexerWorker case operation.to_s when /index/ record = Project.find(record_id) - Client.index index: Project.index_name, type: Project.document_type, id: record.id, body: record.to_json + Client.index index: Project.index_name, type: Project.document_type, id: record.id, body: record.as_indexed_json when /delete/ - Client.delete index: 'fablab', type: 'availabilities', id: record_id + Client.delete index: Project.index_name, type: Project.document_type, id: record_id else raise ArgumentError, "Unknown operation '#{operation}'" end end diff --git a/lib/tasks/fablab.rake b/lib/tasks/fablab.rake index 0fae3524b..6ac805c85 100644 --- a/lib/tasks/fablab.rake +++ b/lib/tasks/fablab.rake @@ -108,7 +108,7 @@ namespace :fablab do client.indices.delete_mapping index: Project.index_name, type: Project.document_type end # create doctype - client.indices.put_mapping index: Project.index_name, type: Project.document_type, body: { settings: Project.settings.to_hash, mappings: Project.mappings.to_hash } + client.indices.put_mapping index: Project.index_name, type: Project.document_type, body: Project.mappings.to_hash # index requested documents if args.id @@ -132,7 +132,7 @@ namespace :fablab do client.indices.delete_mapping index: Availability.index_name, type: Availability.document_type end # create doctype - client.indices.put_mapping index: Availability.index_name, type: Availability.document_type, body: { settings: Availability.settings.to_hash, mappings: Availability.mappings.to_hash } + client.indices.put_mapping index: Availability.index_name, type: Availability.document_type, body: Availability.mappings.to_hash # index requested documents if args.id