Skip to content

Commit

Permalink
Removal of unnecessary features and integrations (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalina-Vakulchyk authored Mar 26, 2021
1 parent f44febc commit 473f7eb
Show file tree
Hide file tree
Showing 37 changed files with 26 additions and 1,957 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
ruby: [2.6, 2.7]
gemfile: [rails.5.2.activerecord, rails.5.2.mongoid.6.4, rails.6.0.activerecord, rails.6.1.activerecord]
gemfile: [rails.5.2.activerecord, rails.6.0.activerecord, rails.6.1.activerecord]
name: ${{ matrix.ruby }}-${{ matrix.gemfile }}

env:
Expand Down
3 changes: 0 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Lint/ConstantDefinitionInBlock:
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'lib/sequel/plugins/chewy_observe.rb'
- 'spec/chewy/minitest/helpers_spec.rb'
- 'spec/chewy/rspec/update_index_spec.rb'
- 'spec/chewy/search/scrolling_spec.rb'
Expand Down Expand Up @@ -122,8 +121,6 @@ Style/IfUnlessModifier:
- 'lib/chewy/railtie.rb'
- 'lib/chewy/rspec/update_index.rb'
- 'lib/chewy/search/query_proxy.rb'
- 'lib/chewy/type/adapter/mongoid.rb'
- 'lib/chewy/type/adapter/sequel.rb'
- 'lib/chewy/type/import.rb'
- 'lib/chewy/type/witchcraft.rb'
- 'spec/support/active_record.rb'
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

### Changes

* [#776](https://github.com/toptal/chewy/pull/776): **(Breaking)** Removal of unnecessary features and integrations ([@Vitalina-Vakulchyk][]):
* `aws-sdk-sqs` / `shoryuken`
* `mongoid`
* `sequel`
* `will_paginate`
* `resque`

* [#769](https://github.com/toptal/chewy/pull/769): **(Breaking)** Removal of deprecated methods and rake tasks ([@Vitalina-Vakulchyk][]):
* `Chewy::Index.index_params` is removed, use `Chewy::Index.specification_hash` instead
* `Chewy::Index.derivable_index_name` is removed, use `Chewy::Index.derivable_name` instead
Expand Down
7 changes: 0 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ source 'https://rubygems.org'
gemspec

gem 'activerecord'
# gem 'mongoid'
# gem 'sequel'

gem 'activejob', require: false
gem 'resque', require: false
gem 'sidekiq', require: false

gem 'aws-sdk-sqs', require: false
gem 'shoryuken', require: false

gem 'kaminari-core', require: false
gem 'will_paginate', require: false

gem 'parallel', require: false
gem 'ruby-progressbar', require: false
Expand Down
50 changes: 5 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ In this section we'll cover why you might want to use Chewy instead of the offic

Chewy has an ActiveRecord-style query DSL. It is chainable, mergeable and lazy, so you can produce queries in the most efficient way. It also has object-oriented query and filter builders.

* Support for ActiveRecord, [Mongoid](https://github.com/mongoid/mongoid) and [Sequel](https://github.com/jeremyevans/sequel).
* Support for ActiveRecord.

## Installation

Expand Down Expand Up @@ -442,29 +442,11 @@ Chewy.settings = {

update_index('cities#city') { self }
update_index 'countries#country' do
# For the latest active_record changed values are
# already in `previous_changes` hash,
# but for mongoid you have to use `changes` hash
previous_changes['country_id'] || country
end
end
```

You can observe Sequel models in the same way as ActiveRecord:

```ruby
class User < Sequel::Model
update_index('users#user') { self }
end
```

However, to make it work, you must load the chewy plugin into Sequel model:

```ruby
Sequel::Model.plugin :chewy_observe # for all models, or...
User.plugin :chewy_observe # just for User
```

### Type default import options

Every type has `default_import_options` configuration to specify, suddenly, default import options:
Expand Down Expand Up @@ -538,7 +520,7 @@ class ProductsIndex < Chewy::Index
end
```

Then the Chewy reindexing flow will look like the following pseudo-code (even in Mongoid):
Then the Chewy reindexing flow will look like the following pseudo-code:

```ruby
Product.includes(:categories).find_in_batches(1000) do |batch|
Expand All @@ -550,9 +532,7 @@ Product.includes(:categories).find_in_batches(1000) do |batch|
end
```

But in Rails 4.1 and 4.2 you may face a problem with slow associations (take a look at https://github.com/rails/rails/pull/19423). Also, there might be really complicated cases when associations are not applicable.

Then you can replace Rails associations with Chewy Crutches™ technology:
If you meet complicated cases when associations are not applicable you can replace Rails associations with Chewy Crutches™ technology:

```ruby
class ProductsIndex < Chewy::Index
Expand Down Expand Up @@ -808,16 +788,6 @@ end

Using this strategy delays the index update request until the end of the block. Updated records are aggregated and the index update happens with the bulk API. So this strategy is highly optimized.

#### `:resque`

This does the same thing as `:atomic`, but asynchronously using resque. The default queue name is `chewy`. Patch `Chewy::Strategy::Resque::Worker` for index updates improving.

```ruby
Chewy.strategy(:resque) do
City.popular.map(&:do_some_update_action!)
end
```

#### `:sidekiq`

This does the same thing as `:atomic`, but asynchronously using sidekiq. Patch `Chewy::Strategy::Sidekiq::Worker` for index updates improving.
Expand Down Expand Up @@ -848,16 +818,6 @@ The default queue name is `chewy`, you can customize it in settings: `active_job
Chewy.settings[:active_job] = {queue: :low}
```

#### `:shoryuken`

This does the same thing as `:atomic`, but asynchronously using shoryuken. Patch `Chewy::Strategy::Shoryuken::Worker` for index updates improving.

```ruby
Chewy.strategy(:shoryuken) do
City.popular.map(&:do_some_update_action!)
end
```

#### `:urgent`

The following strategy is convenient if you are going to update documents in your index one by one.
Expand Down Expand Up @@ -1054,7 +1014,7 @@ Quick introduction.

#### Composing requests

The request DSL have the same chainable nature as AR or Mongoid ones. The main class is `Chewy::Search::Request`. It is possible to perform requests on behalf of indices or types:
The request DSL have the same chainable nature as AR. The main class is `Chewy::Search::Request`. It is possible to perform requests on behalf of indices or types:

```ruby
CitiesIndex.query(match: {name: 'London'}) # or
Expand Down Expand Up @@ -1090,7 +1050,7 @@ Request DSL also provides additional scope actions, like `delete_all`, `exists?`

#### Pagination

The request DSL supports pagination with `Kaminari` and `WillPaginate`. An appropriate extension is enabled on initializtion if any of libraries is available. See [Chewy::Search](lib/chewy/search.rb) and [Chewy::Search::Pagination](lib/chewy/search/pagination/) namespace for details.
The request DSL supports pagination with `Kaminari`. An extension is enabled on initializtion if `Kaminari` is available. See [Chewy::Search](lib/chewy/search.rb) and [Chewy::Search::Pagination::Kaminari](lib/chewy/search/pagination/kaminari.rb) for details.

#### Named scopes

Expand Down
1 change: 0 additions & 1 deletion chewy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
spec.add_development_dependency 'database_cleaner'
spec.add_development_dependency 'elasticsearch-extensions'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'resque_spec'
spec.add_development_dependency 'rspec', '>= 3.7.0'
spec.add_development_dependency 'rspec-collection_matchers'
spec.add_development_dependency 'rspec-its'
Expand Down
4 changes: 0 additions & 4 deletions gemfiles/rails.5.2.activerecord.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ source 'https://rubygems.org'
gem 'activejob', '~> 5.2.0'
gem 'activerecord', '~> 5.2.0'
gem 'activesupport', '~> 5.2.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gemspec path: '../'
15 changes: 0 additions & 15 deletions gemfiles/rails.5.2.mongoid.6.4.gemfile

This file was deleted.

4 changes: 0 additions & 4 deletions gemfiles/rails.6.0.activerecord.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ source 'https://rubygems.org'
gem 'activejob', '~> 6.0.0'
gem 'activerecord', '~> 6.0.0'
gem 'activesupport', '~> 6.0.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gemspec path: '../'
4 changes: 0 additions & 4 deletions gemfiles/rails.6.1.activerecord.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ source 'https://rubygems.org'
gem 'activejob', '~> 6.1.0'
gem 'activerecord', '~> 6.1.0'
gem 'activesupport', '~> 6.1.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gem 'rexml' if RUBY_VERSION >= '3.0.0'

Expand Down
20 changes: 0 additions & 20 deletions lib/chewy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,12 @@ def try_require(path)

try_require 'kaminari'
try_require 'kaminari/core'
try_require 'will_paginate'
try_require 'will_paginate/collection'
try_require 'parallel'

ActiveSupport.on_load(:active_record) do
try_require 'will_paginate/active_record'
try_require 'kaminari/activerecord'
end

ActiveSupport.on_load(:mongoid) do
try_require 'will_paginate/mongoid'
try_require 'kaminari/mongoid'
end

require 'chewy/version'
require 'chewy/errors'
require 'chewy/config'
Expand All @@ -62,21 +54,9 @@ def try_require(path)
extend Chewy::Type::Observe::ActiveRecordMethods
end

ActiveSupport.on_load(:mongoid) do
module Mongoid
module Document
module ClassMethods
include Chewy::Type::Observe::MongoidMethods
end
end
end
end

module Chewy
@adapters = [
Chewy::Type::Adapter::ActiveRecord,
Chewy::Type::Adapter::Mongoid,
Chewy::Type::Adapter::Sequel,
Chewy::Type::Adapter::Object
]

Expand Down
8 changes: 2 additions & 6 deletions lib/chewy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config
# Set number_of_replicas to 0 before reset and put the original value after
# https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
:reset_no_replicas,
# Refresh or not when import async (sidekiq, resque, activejob)
# Refresh or not when import async (sidekiq, activejob)
:disable_refresh_async,
# Default options for root of Chewy type. Allows to set default options
# for type mappings like `_all`.
Expand Down Expand Up @@ -138,11 +138,7 @@ def yaml_settings

def build_search_class(base)
Class.new(base).tap do |search_class|
if defined?(::Kaminari)
search_class.send :include, Chewy::Search::Pagination::Kaminari
elsif defined?(::WillPaginate)
search_class.send :include, Chewy::Search::Pagination::WillPaginate
end
search_class.send :include, Chewy::Search::Pagination::Kaminari if defined?(::Kaminari)
end
end
end
Expand Down
6 changes: 1 addition & 5 deletions lib/chewy/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require 'chewy/search/loader'
require 'chewy/search/request'
require 'chewy/search/pagination/kaminari'
require 'chewy/search/pagination/will_paginate'

module Chewy
# This module being included to any provides an interface to the
Expand All @@ -16,9 +15,7 @@ module Chewy
# The class used as a request DSL provider is
# inherited from {Chewy::Search::Request}
#
# Also, the search class is refined with one of the pagination-
# providing modules: {Chewy::Search::Pagination::Kaminari} or
# {Chewy::Search::Pagination::WillPaginate}.
# Also, the search class is refined with the pagination module {Chewy::Search::Pagination::Kaminari}.
#
# @example
# PlacesIndex.query(match: {name: 'Moscow'})
Expand All @@ -28,7 +25,6 @@ module Chewy
# @see Chewy::Search::Request
# @see Chewy::Search::ClassMethods
# @see Chewy::Search::Pagination::Kaminari
# @see Chewy::Search::Pagination::WillPaginate
module Search
extend ActiveSupport::Concern

Expand Down
43 changes: 0 additions & 43 deletions lib/chewy/search/pagination/will_paginate.rb

This file was deleted.

Loading

0 comments on commit 473f7eb

Please sign in to comment.