1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

fixed rake tasks

This commit is contained in:
Sylvain 2016-09-05 15:30:46 +02:00
parent 701b913eb1
commit d0837706b6
3 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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