Gearheads: merge to Mastodon 4.2.0-beta2
This commit is contained in:
commit
cbd48a29b2
252 changed files with 3630 additions and 2405 deletions
18
lib/chewy/index_extensions.rb
Normal file
18
lib/chewy/index_extensions.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Chewy
|
||||
module IndexExtensions
|
||||
def index_preset(base_options = {})
|
||||
case ENV['ES_PRESET'].presence
|
||||
when 'single_node_cluster', nil
|
||||
base_options.merge(number_of_replicas: 0)
|
||||
when 'small_cluster'
|
||||
base_options.merge(number_of_replicas: 1)
|
||||
when 'large_cluster'
|
||||
base_options.merge(number_of_replicas: 1, number_of_shards: (base_options[:number_of_shards] || 1) * 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Chewy::Index.extend(Chewy::IndexExtensions)
|
11
lib/chewy/settings_extensions.rb
Normal file
11
lib/chewy/settings_extensions.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Chewy
|
||||
module SettingsExtensions
|
||||
def enabled?
|
||||
settings[:enabled]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Chewy.extend(Chewy::SettingsExtensions)
|
8
lib/http_extensions.rb
Normal file
8
lib/http_extensions.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Monkey patching until https://github.com/httprb/http/pull/757 is merged
|
||||
unless HTTP::Request::METHODS.include?(:purge)
|
||||
methods = HTTP::Request::METHODS.dup
|
||||
HTTP::Request.send(:remove_const, :METHODS)
|
||||
HTTP::Request.const_set(:METHODS, methods.push(:purge).freeze)
|
||||
end
|
|
@ -15,9 +15,10 @@ module Mastodon::CLI
|
|||
|
||||
option :concurrency, type: :numeric, default: 5, aliases: [:c], desc: 'Workload will be split between this number of threads'
|
||||
option :batch_size, type: :numeric, default: 100, aliases: [:b], desc: 'Number of records in each batch'
|
||||
option :only, type: :array, enum: %w(accounts tags statuses), desc: 'Only process these indices'
|
||||
option :only, type: :array, enum: %w(instances accounts tags statuses), desc: 'Only process these indices'
|
||||
option :import, type: :boolean, default: true, desc: 'Import data from the database to the index'
|
||||
option :clean, type: :boolean, default: true, desc: 'Remove outdated documents from the index'
|
||||
option :reset_chewy, type: :boolean, default: false, desc: "Reset Chewy's internal index"
|
||||
desc 'deploy', 'Create or upgrade Elasticsearch indices and populate them'
|
||||
long_desc <<~LONG_DESC
|
||||
If Elasticsearch is empty, this command will create the necessary indices
|
||||
|
@ -42,6 +43,8 @@ module Mastodon::CLI
|
|||
importers = indices.index_with { |index| "Importer::#{index.name}Importer".constantize.new(batch_size: options[:batch_size], executor: pool) }
|
||||
progress = ProgressBar.create(total: nil, format: '%t%c/%u |%b%i| %e (%r docs/s)', autofinish: false)
|
||||
|
||||
Chewy::Stash::Specification.reset! if options[:reset_chewy]
|
||||
|
||||
# First, ensure all indices are created and have the correct
|
||||
# structure, so that live data can already be written
|
||||
indices.select { |index| index.specification.changed? }.each do |index|
|
||||
|
|
|
@ -17,7 +17,7 @@ module Mastodon
|
|||
end
|
||||
|
||||
def flags
|
||||
ENV.fetch('MASTODON_VERSION_FLAGS', '-beta1')
|
||||
ENV.fetch('MASTODON_VERSION_FLAGS', '-beta2')
|
||||
end
|
||||
|
||||
def suffix
|
||||
|
|
|
@ -49,8 +49,8 @@ namespace :repo do
|
|||
File.open(path, 'r') do |file|
|
||||
file.each_line do |line|
|
||||
if line.start_with?('-')
|
||||
new_line = line.gsub(/#([[:digit:]]+)*/) do |pull_request_reference|
|
||||
pull_request_number = pull_request_reference[1..]
|
||||
new_line = line.gsub(/[(]#([[:digit:]]+)[)]\Z/) do |pull_request_reference|
|
||||
pull_request_number = pull_request_reference[2..-2]
|
||||
response = nil
|
||||
|
||||
loop do
|
||||
|
@ -66,7 +66,7 @@ namespace :repo do
|
|||
end
|
||||
|
||||
pull_request = Oj.load(response.to_s)
|
||||
"[#{pull_request['user']['login']}](#{pull_request['html_url']})"
|
||||
"([#{pull_request['user']['login']}](#{pull_request['html_url']}))"
|
||||
end
|
||||
|
||||
tmp.puts new_line
|
||||
|
|
Reference in a new issue