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

Removal of unnecessary features and integrations #776

Merged
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
3b4b9a5
Remove will_paginate gem from gemfiles
Vitalina-Vakulchyk Mar 22, 2021
069060a
Remove will_paginate module from Chewy#Search#Pagination
Vitalina-Vakulchyk Mar 22, 2021
80de8c1
Remove will_paginate from lib/chewy.rb
Vitalina-Vakulchyk Mar 22, 2021
bce4560
Remove will_paginate from lib/chewy/search.rb
Vitalina-Vakulchyk Mar 22, 2021
b90876c
Remove spec for Chewy::Search::Pagination::WillPaginate
Vitalina-Vakulchyk Mar 22, 2021
ffe322c
Remove will_paginate_examples.rb for will_paginate module spec
Vitalina-Vakulchyk Mar 22, 2021
d78d301
Remove will_paginate specs from config_spec.rb
Vitalina-Vakulchyk Mar 22, 2021
f97701f
Update CHANGELOG with drop will_paginate support
Vitalina-Vakulchyk Mar 22, 2021
b9de918
Rubocop it
Vitalina-Vakulchyk Mar 22, 2021
fe9d7c1
Remove will_paginate comments from /lib/chewy/search.rb
Vitalina-Vakulchyk Mar 23, 2021
1991d43
Remove resque from gemfile
Vitalina-Vakulchyk Mar 23, 2021
077f5a1
Remove resque from chewy.gemspec
Vitalina-Vakulchyk Mar 23, 2021
c5f23e2
Remove resque from gemfiles
Vitalina-Vakulchyk Mar 23, 2021
aa796e1
Remove resque from lib/chewy/strategy.rb
Vitalina-Vakulchyk Mar 23, 2021
39ffa46
Remove lib/chewy/strategy/resque.rb
Vitalina-Vakulchyk Mar 23, 2021
1239030
Resque: Remove spec/chewy/strategy/resque_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
99e0d5f
Resque: Remove resque from Readme
Vitalina-Vakulchyk Mar 23, 2021
b90c3f6
Resque: Remove resque from /lib/chewy/config.rb
Vitalina-Vakulchyk Mar 23, 2021
134353d
Resque: mark as removed in CHANGELOG
Vitalina-Vakulchyk Mar 23, 2021
7b754cc
Mongoid: Remove adapter
Vitalina-Vakulchyk Mar 23, 2021
501b001
Mongoid: Adapt spec/chewy/type/import_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
2c7069b
Mongoid: remove spec/support/mongoid.rb
Vitalina-Vakulchyk Mar 23, 2021
d6c0b7e
Mongoid: remove mongoid from spec/chewy/fields/base_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
a0c40cf
Mongoid: remove from gemfile
Vitalina-Vakulchyk Mar 23, 2021
aae9306
Mongoid: remove file from gemfiles
Vitalina-Vakulchyk Mar 23, 2021
440330b
Mongoid: Remove from CI
Vitalina-Vakulchyk Mar 23, 2021
8a9eeb4
Mongoid: remove mongoid from spec/chewy/query/loading_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
61538f9
Mongoid: remove spec/chewy/type/adapter/mongoid_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
5010b7a
Mongoid: remove mongoid from spec/spec_helper.rb
Vitalina-Vakulchyk Mar 23, 2021
db916e1
Mongoid: remove mongoid from spec/support/active_record.rb
Vitalina-Vakulchyk Mar 23, 2021
9cf2a24
Mongoid: remove mongoid from spec/chewy/type/observe_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
d02b897
Mongoid: remove mongoid from lib/chewy.rb
Vitalina-Vakulchyk Mar 23, 2021
1477310
Mongoid: remove mongoid from lib/chewy/type.rb
Vitalina-Vakulchyk Mar 23, 2021
6368848
Mongoid: remove MongoidMethods module from lib/chewy/type/observe.rb
Vitalina-Vakulchyk Mar 23, 2021
a8a878d
Mongoid: remove mongoid from spec/support/sequel.rb
Vitalina-Vakulchyk Mar 23, 2021
7c73876
Mongoid: remove mongoid comment from lib/chewy/strategy.rb
Vitalina-Vakulchyk Mar 23, 2021
fcf7254
Mongoid: remove from .rubocop_todo.yml
Vitalina-Vakulchyk Mar 23, 2021
82081b9
Mongoid: remove from Readme
Vitalina-Vakulchyk Mar 23, 2021
0a2380e
Mongoid: mark mongoid gem as deprecated at CHANGELOG
Vitalina-Vakulchyk Mar 23, 2021
8b71d71
WillPaginate: Formulation update at CHANGELOG
Vitalina-Vakulchyk Mar 23, 2021
9e3f2f7
Sequel: remove from spec/chewy/fields/base_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
6231ade
Sequel: remove from /spec/chewy/type/observe_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
c21de59
Sequel: remove from spec/support/active_record.rb
Vitalina-Vakulchyk Mar 23, 2021
7c6dcd6
Sequel: remove from /spec/support/sequel.rb
Vitalina-Vakulchyk Mar 23, 2021
a866dc4
Sequel: remove /lib/chewy/type/adapter/sequel.rb
Vitalina-Vakulchyk Mar 23, 2021
e2dadc4
Sequel: spec/chewy/type/adapter/sequel_spec.rb
Vitalina-Vakulchyk Mar 23, 2021
fcbc648
Sequel: remove /lib/sequel/ plugin
Vitalina-Vakulchyk Mar 23, 2021
2b2ba36
Sequel: remove from gemfile
Vitalina-Vakulchyk Mar 23, 2021
9b7ad10
Sequel: remove sequel from spec/spec_helper.rb
Vitalina-Vakulchyk Mar 23, 2021
6d6920f
Sequel: remove sequel from /lib/chewy.rb
Vitalina-Vakulchyk Mar 23, 2021
5c5e819
Sequel: remove sequel from /lib/chewy/type.rb
Vitalina-Vakulchyk Mar 23, 2021
c7853e2
Sequel: mark sequel as deprecated at CHANGELOG
Vitalina-Vakulchyk Mar 23, 2021
67f22d8
Sequel: remove sequel from Readme
Vitalina-Vakulchyk Mar 23, 2021
978f904
Sequel: remove sequel from .rubocop_todo.yml
Vitalina-Vakulchyk Mar 23, 2021
01abfb7
Remove `` from CHANGELOG gems changes
Vitalina-Vakulchyk Mar 24, 2021
dc5b193
aws-sdk-sqs: remove from gemfiles
Vitalina-Vakulchyk Mar 24, 2021
cc90935
aws-sdk-sqs: remove from Gemfile
Vitalina-Vakulchyk Mar 24, 2021
094c8da
aws-sdk-sqs: remove from spec/chewy/strategy/shoryuken_spec.rb
Vitalina-Vakulchyk Mar 24, 2021
d6fdc65
Shoryuken: remove from Gemfile
Vitalina-Vakulchyk Mar 24, 2021
642401d
Shoryuken: remove from gemfiles
Vitalina-Vakulchyk Mar 24, 2021
9148460
Shoryuken: remove from lib/chewy/strategy.rb
Vitalina-Vakulchyk Mar 24, 2021
bcabbed
Shoryuken: remove lib/chewy/strategy/shoryuken.rb
Vitalina-Vakulchyk Mar 24, 2021
a767716
Shoryuken: remove spec/chewy/strategy/shoryuken_spec.rb
Vitalina-Vakulchyk Mar 24, 2021
fe66522
Update dropped gems order at CHANGELOG
Vitalina-Vakulchyk Mar 24, 2021
53afb1e
Shoryuken: mark as deprecated at CHANGELOG
Vitalina-Vakulchyk Mar 24, 2021
c3c64a2
Shoryuken: remove from Readme
Vitalina-Vakulchyk Mar 24, 2021
87f1c16
aws-sdk-sqs gem: mark as deprecated at CHANGELOG
Vitalina-Vakulchyk Mar 24, 2021
48c4d61
Update dropped description at CHANGELOG
Vitalina-Vakulchyk Mar 24, 2021
4251d14
Update PR number and link at CHANGELOG
Vitalina-Vakulchyk Mar 24, 2021
64faf84
WillPaginate: remove from chewy/lib/chewy/config.rb
Vitalina-Vakulchyk Mar 25, 2021
3f06c66
Update CHANGELOG with deprecated gems order
Vitalina-Vakulchyk Mar 25, 2021
8a5054f
Remove `previous_changes` hash comment from Readme
Vitalina-Vakulchyk Mar 25, 2021
777eec4
Rephrase associations with Chewy Crutches part in Readme
Vitalina-Vakulchyk Mar 25, 2021
e6108f4
Update pagination module comment in lib/chewy/search.rb
Vitalina-Vakulchyk Mar 25, 2021
1ddd405
Remove rescue from debug def at lib/chewy/strategy.rb
Vitalina-Vakulchyk Mar 25, 2021
37d176a
WillPaginate: remove from spec/chewy/config_spec.rb
Vitalina-Vakulchyk Mar 25, 2021
b952cf1
Remove adapter support and AR<5.2 from spec/chewy/fields/base_spec.rb
Vitalina-Vakulchyk Mar 25, 2021
d52d084
aws-sdk-sqs: remove from spec/spec_helper.rb
Vitalina-Vakulchyk Mar 25, 2021
a9a9ada
Not run specs without AR
Vitalina-Vakulchyk Mar 25, 2021
488e0bd
Rubocop it
Vitalina-Vakulchyk Mar 25, 2021
9b0ede7
Update spec/chewy/fields/base_spec.rb for ActiveRecord >= 4
Vitalina-Vakulchyk Mar 26, 2021
6d8a2b5
Update Readme for solve complicated cases with associations
Vitalina-Vakulchyk Mar 26, 2021
1d2cdfd
Inline arg for integration spec in spec/chewy/type/observe_spec.rb
Vitalina-Vakulchyk Mar 26, 2021
a692cbe
Remove will_paginate from Readme
Vitalina-Vakulchyk Mar 26, 2021
39aa13a
Remove AR conditions from spec/spec_helper.rb
Vitalina-Vakulchyk Mar 26, 2021
68038ee
Update block passing to update_index in spec/chewy/type/observe_spec.rb
Vitalina-Vakulchyk Mar 26, 2021
04e43a6
Update kaminari in Readme
Vitalina-Vakulchyk Mar 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`
Vitalina-Vakulchyk marked this conversation as resolved.
Show resolved Hide resolved
* `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
48 changes: 4 additions & 44 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
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