Skip to content

Commit

Permalink
Remove Chewy::Type, simplify DSL: (#783)
Browse files Browse the repository at this point in the history
- Remove the `Chewy::Type` class
    - e.g. remove `CitiesIndex::City` / `CitiesIndex.city`
      - `CitiesIndex::City.import! ...` becomes `CitiesIndex.import! ...`
  - Simplify index DSL:
    - `define_type` block -> `index_scope` clause
      - it can be omitted completely, if you don't need to specify the scope or options, e.g. `name`
  - Remove type names from string representations:
    - in `update_index` ActiveRecord helper and RSpec matcher, e.g.
      - `update_index('cities#city')` -> `update_index('cities')`
      - `update_index(UsersIndex::User)` -> `update_index(UsersIndex)`
    - in rake tasks (e.g. `rake chewy:update[cities#city]` -> `rake chewy:update[cities]`)
    - in rake tasks output (e.g. `Imported CitiesIndex::City in 1s, stats: index 3` -> `Imported CitiesIndex in 1s, stats: index 3`)
  - Use index name instead of type name in loader additional scope
    - e.g. `CitiesIndex.filter(...).load(city: {scope: City.where(...)})` -> `CitiesIndex.filter(...).load(cities: {scope: City.where(...)})`
  • Loading branch information
Ivan Rabotyaga committed Apr 19, 2021
1 parent 6a9cf13 commit a349bf6
Show file tree
Hide file tree
Showing 77 changed files with 1,496 additions and 2,226 deletions.
16 changes: 8 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ Lint/EmptyBlock:
- 'spec/chewy/search/scrolling_spec.rb'
- 'spec/chewy/strategy/atomic_spec.rb'
- 'spec/chewy/strategy_spec.rb'
- 'spec/chewy/type/import/bulk_request_spec.rb'
- 'spec/chewy/type/witchcraft_spec.rb'
- 'spec/chewy/index/import/bulk_request_spec.rb'
- 'spec/chewy/index/witchcraft_spec.rb'
- 'spec/chewy_spec.rb'

# Offense count: 3
Lint/MissingSuper:
Exclude:
- 'lib/chewy/strategy/atomic.rb'
- 'lib/chewy/type/adapter/object.rb'
- 'lib/chewy/type/adapter/orm.rb'
- 'lib/chewy/index/adapter/object.rb'
- 'lib/chewy/index/adapter/orm.rb'

# Offense count: 35
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Expand Down Expand Up @@ -85,8 +85,8 @@ Style/DocumentDynamicEvalDefinition:
- 'lib/chewy/index/actions.rb'
- 'lib/chewy/repository.rb'
- 'lib/chewy/search/pagination/kaminari.rb'
- 'lib/chewy/type/crutch.rb'
- 'lib/chewy/type/witchcraft.rb'
- 'lib/chewy/index/crutch.rb'
- 'lib/chewy/index/witchcraft.rb'

# Offense count: 58
Style/Documentation:
Expand Down Expand Up @@ -120,8 +120,8 @@ Style/IfUnlessModifier:
- 'lib/chewy/railtie.rb'
- 'lib/chewy/rspec/update_index.rb'
- 'lib/chewy/search/query_proxy.rb'
- 'lib/chewy/type/import.rb'
- 'lib/chewy/type/witchcraft.rb'
- 'lib/chewy/index/import.rb'
- 'lib/chewy/index/witchcraft.rb'
- 'spec/support/active_record.rb'

# Offense count: 53
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@

### Changes

* [#783](https://github.com/toptal/chewy/pull/783): **(Breaking)** Remove `Chewy::Type`, simplify DSL ([@rabotyaga][])
* Remove the `Chewy::Type` class
* e.g. remove `CitiesIndex::City` / `CitiesIndex.city`
* `CitiesIndex::City.import! ...` becomes `CitiesIndex.import! ...`
* Simplify index DSL:
* `define_type` block -> `index_scope` clause
* it can be omitted completely, if you don't need to specify the scope or options, e.g. `name`
* Remove type names from string representations:
* in `update_index` ActiveRecord helper and RSpec matcher, e.g.
* `update_index('cities#city')` -> `update_index('cities')`
* `update_index(UsersIndex::User)` -> `update_index(UsersIndex)`
* in rake tasks (e.g. `rake chewy:update[cities#city]` -> `rake chewy:update[cities]`)
* in rake tasks output (e.g. `Imported CitiesIndex::City in 1s, stats: index 3` -> `Imported CitiesIndex in 1s, stats: index 3`)
* Use index name instead of type name in loader additional scope
* e.g. `CitiesIndex.filter(...).load(city: {scope: City.where(...)})` -> `CitiesIndex.filter(...).load(cities: {scope: City.where(...)})`
* [#692](https://github.com/toptal/chewy/issues/692): Add `.update_mapping` to Index class ([@Vitalina-Vakulchyk][]):
* Wrapped Elasticsearch gem `.put_mapping` with `.update_mapping` in Index class
* Add `rake chewy:update_mapping` task
Expand Down
Loading

0 comments on commit a349bf6

Please sign in to comment.