Skip to content

Commit

Permalink
Remove Chewy::Type, simplify DSL: (toptal#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 authored and Çağatay Yücelen committed Jan 28, 2023
1 parent 7095897 commit f5d88a8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 215 deletions.
44 changes: 0 additions & 44 deletions lib/chewy/type/import/journal_builder.rb

This file was deleted.

28 changes: 0 additions & 28 deletions spec/chewy/fields/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
end

specify do
<<<<<<< HEAD
expect(EventsIndex.mappings_hash).to eq(
mappings: {
properties: {
Expand All @@ -160,20 +159,6 @@
id: {type: 'integer'},
created_at: {type: 'time'}
}
=======
expect(EventsIndex::Event.mappings_hash).to eq(
properties: {
id: {type: 'integer'},
category: {
type: 'object',
properties: {
id: {type: 'integer'},
licenses: {
type: 'object',
properties: {
id: {type: 'integer'},
created_at: {type: 'time'}
>>>>>>> e3d155a (Drop support for Elasticsearch 6.x, prepare 7.1.0 release (#766))
}
}
}
Expand Down Expand Up @@ -345,7 +330,6 @@
end

specify do
<<<<<<< HEAD
expect(EventsIndex.mappings_hash).to eq(
mappings: {
properties: {
Expand All @@ -358,18 +342,6 @@
},
category: {type: 'object'}
}
=======
expect(EventsIndex::Event.mappings_hash).to eq(
properties: {
id: {type: 'integer'},
name: {
type: 'integer',
fields: {
raw: {analyzer: 'my_own', type: Chewy.default_field_type}
}
},
category: {type: 'object'}
>>>>>>> e3d155a (Drop support for Elasticsearch 6.x, prepare 7.1.0 release (#766))
}
)
end
Expand Down
143 changes: 0 additions & 143 deletions spec/chewy/type/mapping_spec.rb

This file was deleted.

0 comments on commit f5d88a8

Please sign in to comment.