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 Chewy::Type, simplify DSL #783

Merged
merged 1 commit into from
Apr 19, 2021
Merged

Remove Chewy::Type, simplify DSL #783

merged 1 commit into from
Apr 19, 2021

Conversation

rabotyaga
Copy link
Contributor

@rabotyaga rabotyaga commented Apr 7, 2021

Remove the type concept from internals completely, as Elasticsearch is removing types:

  • 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(...)})

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the changelog if the new code introduces user-observable changes. See changelog entry format for details.

@rabotyaga rabotyaga self-assigned this Apr 7, 2021
@rabotyaga rabotyaga force-pushed the remove-types branch 4 times, most recently from e347bca to 5e3bc7f Compare April 15, 2021 15:34
@rabotyaga rabotyaga marked this pull request as ready for review April 16, 2021 10:42
lib/chewy/index.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@dalthon dalthon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that most of the work was based to move modules that once were included at Chewy::Type to Chewy::Index, and changing edge cases like index_scope, it LGTM!

  - 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(...)})`
@rabotyaga rabotyaga merged commit a349bf6 into master Apr 19, 2021
@rabotyaga rabotyaga deleted the remove-types branch April 19, 2021 11:57
cyucelen pushed a commit to cyucelen/chewy that referenced this pull request Jan 28, 2023
- 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(...)})`
cyucelen pushed a commit to cyucelen/chewy that referenced this pull request Jan 28, 2023
- 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(...)})`
@ql ql mentioned this pull request Aug 16, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants