diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-15 21:08:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-15 21:08:34 +0300 |
commit | 571d993b49313dd806bd3f6af16d36c26d9d28ca (patch) | |
tree | 06bd12c4b56b97881aef8a00d4d46698de1eb63f /config | |
parent | 9044365a91112d426fbbfba07eca595652bbe2df (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/elastic_client_setup.rb | 26 | ||||
-rw-r--r-- | config/routes/project.rb | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/config/initializers/elastic_client_setup.rb b/config/initializers/elastic_client_setup.rb index f38b606b3a8..21745bd81d8 100644 --- a/config/initializers/elastic_client_setup.rb +++ b/config/initializers/elastic_client_setup.rb @@ -18,6 +18,32 @@ Gitlab.ee do Elasticsearch::Model::ClassMethods.prepend GemExtensions::Elasticsearch::Model::Client Elasticsearch::Model.singleton_class.prepend GemExtensions::Elasticsearch::Model::Client + # This monkey patch cannot be handled by prepend like the above since this + # module is included into other classes. + module Elasticsearch + module Model + module Response + module Base + if Gem::Version.new(Elasticsearch::Model::VERSION) >= Gem::Version.new('7.0.0') + raise "elasticsearch-model was upgraded, please remove this monkey patch in #{__FILE__}" + end + + # Handle ES7 API where total is returned as an object. This + # change is taken from the V7 gem + # https://github.com/elastic/elasticsearch-rails/commit/9c40f630e1b549f0b7889fe33dcd826b485af6fc + # and can be removed when we upgrade the gem to V7 + def total + if response.response['hits']['total'].respond_to?(:keys) + response.response['hits']['total']['value'] + else + response.response['hits']['total'] + end + end + end + end + end + end + ### Modified from elasticsearch-model/lib/elasticsearch/model.rb [ diff --git a/config/routes/project.rb b/config/routes/project.rb index 3bc38ef3349..09e6b733bff 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -242,7 +242,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do get '/prometheus/api/v1/*proxy_path', to: 'environments/prometheus_api#proxy', as: :prometheus_api - get '/sample_metrics', to: 'environments/sample_metrics#query' if ENV['USE_SAMPLE_METRICS'] + get '/sample_metrics', to: 'environments/sample_metrics#query' end collection do |