From 2419a96010f29038488d370f9469809555bc8241 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 28 Feb 2017 17:49:19 +0100 Subject: [PATCH] spaces stats index in elastic --- CHANGELOG.md | 1 + lib/tasks/fablab.rake | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cc93d530..3323cd000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Fix a bug: unable to delete an administrator from the system - [TODO DEPLOY] `rake db:migrate`, then `rake db:seed` - [TODO DEPLOY] add the `FABLAB_WITHOUT_SPACES` environment variable +- [TODO DEPLOY] `rake fablab:es_add_spaces` ## v2.4.10 2017 January 9 diff --git a/lib/tasks/fablab.rake b/lib/tasks/fablab.rake index 1ee489b0c..12d1cdf16 100644 --- a/lib/tasks/fablab.rake +++ b/lib/tasks/fablab.rake @@ -49,7 +49,7 @@ namespace :fablab do puts "PUT index stats" `curl -XPUT http://#{ENV["ELASTICSEARCH_HOST"]}:9200/stats` - %w[account event machine project subscription training user].each do |stat| + %w[account event machine project subscription training user space].each do |stat| puts "PUT Mapping stats/#{stat}" `curl -XPUT http://#{ENV["ELASTICSEARCH_HOST"]}:9200/stats/#{stat}/_mapping -d ' { @@ -96,6 +96,31 @@ namespace :fablab do }';` end + + desc 'add spaces reservations to statistics' + task es_add_spaces: :environment do + `curl -XPUT http://#{ENV["ELASTICSEARCH_HOST"]}:9200/stats/space/_mapping -d ' + { + "properties": { + "type": { + "type": "string", + "index" : "not_analyzed" + }, + "subType": { + "type": "string", + "index" : "not_analyzed" + }, + "date": { + "type": "date" + }, + "name": { + "type": "string", + "index" : "not_analyzed" + } + } + }';` + end + desc 'sync all/one project in ElasticSearch index' task :es_build_projects_index, [:id] => :environment do |task, args| client = Project.__elasticsearch__.client