diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-03-29 16:39:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-29 16:39:43 +0200 |
commit | eaea849035ea407afb2d5db411dbddc1ccca6f44 (patch) | |
tree | 19a0b6e761fc453fac2f5a8aba24595ad93f0382 /app/lib/admin/system_check | |
parent | 2287eebae0c1d699436a8cf3218d7cfe990a3605 (diff) | |
parent | 8d6f3f8a379c8d552d2101cf35ae8f6fe956da53 (diff) |
Merge pull request #1724 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/lib/admin/system_check')
-rw-r--r-- | app/lib/admin/system_check/elasticsearch_check.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/lib/admin/system_check/elasticsearch_check.rb b/app/lib/admin/system_check/elasticsearch_check.rb new file mode 100644 index 000000000..1b48a5415 --- /dev/null +++ b/app/lib/admin/system_check/elasticsearch_check.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck + def pass? + return true unless Chewy.enabled? + + running_version.present? && compatible_version? + end + + def message + if running_version.present? + Admin::SystemCheck::Message.new(:elasticsearch_version_check, I18n.t('admin.system_checks.elasticsearch_version_check.version_comparison', running_version: running_version, required_version: required_version)) + else + Admin::SystemCheck::Message.new(:elasticsearch_running_check) + end + end + + private + + def running_version + @running_version ||= begin + Chewy.client.info['version']['number'] + rescue Faraday::ConnectionFailed + nil + end + end + + def required_version + '7.x' + end + + def compatible_version? + Gem::Version.new(running_version) >= Gem::Version.new(required_version) + end + + def missing_queues + @missing_queues ||= Sidekiq::ProcessSet.new.reduce(SIDEKIQ_QUEUES) { |queues, process| queues - process['queues'] } + end +end |