Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated methods and rake tasks #769

Merged
merged 9 commits into from
Mar 15, 2021
22 changes: 1 addition & 21 deletions lib/chewy/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,12 @@ def specification_hash
[settings_hash, mappings_hash].inject(:merge)
end

def index_params
ActiveSupport::Deprecation.warn '`Chewy::Index.index_params` is deprecated and will be removed soon, use `Chewy::Index.specification_hash`'
specification_hash
end

# @see Chewy::Index::Specification
# @return [Chewy::Index::Specification] a specification object instance for this particular index
def specification
@specification ||= Specification.new(self)
end

def derivable_index_name
ActiveSupport::Deprecation.warn '`Chewy::Index.derivable_index_name` is deprecated and will be removed soon, use `Chewy::Index.derivable_name` instead'
derivable_name
end
Vitalina-Vakulchyk marked this conversation as resolved.
Show resolved Hide resolved

# Handling old default_prefix if it is not defined.
def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing
if name == :default_prefix
Expand All @@ -250,17 +240,7 @@ def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing
end

def prefix_with_deprecation
if respond_to?(:default_prefix)
ActiveSupport::Deprecation.warn '`Chewy::Index.default_prefix` is deprecated and will be removed soon, define `Chewy::Index.prefix` method instead'
default_prefix
else
prefix
end
end

def build_index_name(*args)
ActiveSupport::Deprecation.warn '`Chewy::Index.build_index_name` is deprecated and will be removed soon, use `Chewy::Index.index_name` instead'
index_name(args.extract_options!)
prefix
Vitalina-Vakulchyk marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
Expand Down
20 changes: 0 additions & 20 deletions lib/chewy/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,6 @@ def subscribed_task_stats(output = STDOUT)
output.puts "Total: #{human_duration(Time.now - start)}"
end

def reset_index(*indexes)
ActiveSupport::Deprecation.warn '`Chewy::RakeHelper.reset_index` is deprecated and will be removed soon, use `Chewy::RakeHelper.reset` instead'
reset(only: indexes)
end

def reset_all(*except)
ActiveSupport::Deprecation.warn '`Chewy::RakeHelper.reset_all` is deprecated and will be removed soon, use `Chewy::RakeHelper.reset` instead'
reset(except: except)
end

def update_index(*indexes)
ActiveSupport::Deprecation.warn '`Chewy::RakeHelper.update_index` is deprecated and will be removed soon, use `Chewy::RakeHelper.update` instead'
update(only: indexes)
end

def update_all(*except)
ActiveSupport::Deprecation.warn '`Chewy::RakeHelper.update_all` is deprecated and will be removed soon, use `Chewy::RakeHelper.update` instead'
update(except: except)
end

private

def indexes_from(only: nil, except: nil)
Expand Down
22 changes: 0 additions & 22 deletions lib/tasks/chewy.rake
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,4 @@ namespace :chewy do
Chewy::RakeHelper.journal_clean(**parse_journal_args(args.extras))
end
end

task apply_changes_from: :environment do |_task, args|
ActiveSupport::Deprecation.warn '`rake chewy:apply_changes_from` is deprecated and will be removed soon, use `rake chewy:journal:apply` instead'

Chewy::RakeHelper.subscribed_task_stats do
params = args.extras

if params.empty?
puts 'Please specify a timestamp like chewy:apply_changes_from[1469528705]'
else
timestamp, retries = params
time = Time.at(timestamp.to_i)
Chewy::Journal.new.apply(time, retries: (retries.to_i if retries))
end
end
end

task clean_journal: :environment do |_task, args|
ActiveSupport::Deprecation.warn '`rake chewy:clean_journal` is deprecated and will be removed soon, use `rake chewy:journal:clean` instead'

Chewy::Journal.new.clean(args.extras.first)
end
end
22 changes: 0 additions & 22 deletions spec/chewy/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,28 +263,6 @@ def self.by_id; end
specify { expect(subject.specification).to equal(subject.specification) }
end

describe '.default_prefix' do
before { allow(Chewy).to receive_messages(configuration: {prefix: 'testing'}) }

context do
before { expect(ActiveSupport::Deprecation).to receive(:warn).once }
specify { expect(DummiesIndex.default_prefix).to eq('testing') }
end

context do
before do
DummiesIndex.class_eval do
def self.default_prefix
'borogoves'
end
end
end

before { expect(ActiveSupport::Deprecation).to receive(:warn).once }
specify { expect(DummiesIndex.index_name).to eq('borogoves_dummies') }
end
end

context 'index call inside index', :orm do
before do
stub_index(:cities) do
Expand Down