Skip to content

Commit

Permalink
Fix Elastic check deprecation warning about gem version (mastodon#27262)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored and audiodude committed Oct 23, 2023
1 parent f617928 commit 86c3849
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions app/lib/admin/system_check/elasticsearch_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,35 @@ def required_version
end

def compatible_version?
return false if running_version.nil?

Gem::Version.new(running_version) >= Gem::Version.new(required_version) ||
Gem::Version.new(compatible_wire_version) >= Gem::Version.new(required_version)
running_version_ok? || compatible_wire_version_ok?
rescue ArgumentError
false
end

def running_version_ok?
return false if running_version.blank?

gem_version_running >= gem_version_required
end

def compatible_wire_version_ok?
return false if compatible_wire_version.blank?

gem_version_compatible_wire >= gem_version_required
end

def gem_version_running
Gem::Version.new(running_version)
end

def gem_version_required
Gem::Version.new(required_version)
end

def gem_version_compatible_wire
Gem::Version.new(compatible_wire_version)
end

def mismatched_indexes
@mismatched_indexes ||= INDEXES.filter_map do |klass|
klass.base_name if Chewy.client.indices.get_mapping[klass.index_name]&.deep_symbolize_keys != klass.mappings_hash
Expand Down

0 comments on commit 86c3849

Please sign in to comment.