Commit 953af9dfc099a6612c1c3f24b71e94bb1aeb18eb

Authored by Andrew Kane
1 parent 7c73e489

Dropped support for NoBrainer and Cequel [skip ci]

1 ## 5.0.0 (unreleased) 1 ## 5.0.0 (unreleased)
2 2
3 - Dropped support for Ruby < 2.6 and Active Record < 5.2 3 - Dropped support for Ruby < 2.6 and Active Record < 5.2
  4 +- Dropped support for NoBrainer and Cequel
4 5
5 ## 4.6.3 (2021-11-19) 6 ## 4.6.3 (2021-11-19)
6 7
@@ -20,7 +20,7 @@ Plus: @@ -20,7 +20,7 @@ Plus:
20 - autocomplete 20 - autocomplete
21 - “Did you mean” suggestions 21 - “Did you mean” suggestions
22 - supports many languages 22 - supports many languages
23 -- works with Active Record, Mongoid, and NoBrainer 23 +- works with Active Record and Mongoid
24 24
25 Check out [Searchjoy](https://github.com/ankane/searchjoy) for analytics and [Autosuggest](https://github.com/ankane/autosuggest) for query suggestions 25 Check out [Searchjoy](https://github.com/ankane/searchjoy) for analytics and [Autosuggest](https://github.com/ankane/autosuggest) for query suggestions
26 26
gemfiles/cequel.gemfile
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 -source "https://rubygems.org"  
2 -  
3 -gemspec path: ".."  
4 -  
5 -gem "rake"  
6 -gem "minitest", ">= 5"  
7 -gem "cequel"  
8 -gem "activejob"  
9 -gem "redis"  
gemfiles/nobrainer.gemfile
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 -source "https://rubygems.org"  
2 -  
3 -gemspec path: ".."  
4 -  
5 -gem "rake"  
6 -gem "minitest", ">= 5"  
7 -gem "nobrainer", ">= 0.21.0"  
8 -gem "activejob"  
9 -gem "redis"  
lib/searchkick.rb
@@ -223,9 +223,6 @@ module Searchkick @@ -223,9 +223,6 @@ module Searchkick
223 elsif records.respond_to?(:queryable) 223 elsif records.respond_to?(:queryable)
224 # Mongoid 3+ 224 # Mongoid 3+
225 records.queryable.for_ids(ids) 225 records.queryable.for_ids(ids)
226 - elsif records.respond_to?(:unscoped) && :id.respond_to?(:in)  
227 - # Nobrainer  
228 - records.unscoped.where(:id.in => ids)  
229 elsif records.respond_to?(:key_column_names) 226 elsif records.respond_to?(:key_column_names)
230 records.where(records.key_column_names.first => ids) 227 records.where(records.key_column_names.first => ids)
231 end 228 end
lib/searchkick/model.rb
@@ -99,12 +99,6 @@ module Searchkick @@ -99,12 +99,6 @@ module Searchkick
99 def should_index? 99 def should_index?
100 true 100 true
101 end unless method_defined?(:should_index?) 101 end unless method_defined?(:should_index?)
102 -  
103 - if defined?(Cequel) && self < Cequel::Record && !method_defined?(:destroyed?)  
104 - def destroyed?  
105 - transient?  
106 - end  
107 - end  
108 end 102 end
109 end 103 end
110 end 104 end
lib/searchkick/reindex_v2_job.rb
@@ -2,9 +2,7 @@ module Searchkick @@ -2,9 +2,7 @@ module Searchkick
2 class ReindexV2Job < ActiveJob::Base 2 class ReindexV2Job < ActiveJob::Base
3 RECORD_NOT_FOUND_CLASSES = [ 3 RECORD_NOT_FOUND_CLASSES = [
4 "ActiveRecord::RecordNotFound", 4 "ActiveRecord::RecordNotFound",
5 - "Mongoid::Errors::DocumentNotFound",  
6 - "NoBrainer::Error::DocumentNotFound",  
7 - "Cequel::Record::RecordNotFound" 5 + "Mongoid::Errors::DocumentNotFound"
8 ] 6 ]
9 7
10 queue_as { Searchkick.queue_name } 8 queue_as { Searchkick.queue_name }
lib/searchkick/results.rb
@@ -309,16 +309,7 @@ module Searchkick @@ -309,16 +309,7 @@ module Searchkick
309 combine_includes(included_relations, options[:includes]) 309 combine_includes(included_relations, options[:includes])
310 combine_includes(included_relations, options[:model_includes][records]) if options[:model_includes] 310 combine_includes(included_relations, options[:model_includes][records]) if options[:model_includes]
311 311
312 - records =  
313 - if defined?(NoBrainer::Document) && records < NoBrainer::Document  
314 - if Gem.loaded_specs["nobrainer"].version >= Gem::Version.new("0.21")  
315 - records.eager_load(included_relations)  
316 - else  
317 - records.preload(included_relations)  
318 - end  
319 - else  
320 - records.includes(included_relations)  
321 - end 312 + records = records.includes(included_relations)
322 end 313 end
323 314
324 if options[:scope_results] 315 if options[:scope_results]
test/boost_test.rb
@@ -171,8 +171,6 @@ class BoostTest &lt; Minitest::Test @@ -171,8 +171,6 @@ class BoostTest &lt; Minitest::Test
171 end 171 end
172 172
173 def test_boost_by_indices 173 def test_boost_by_indices
174 - skip if cequel?  
175 -  
176 store_names ["Rex"], Animal 174 store_names ["Rex"], Animal
177 store_names ["Rexx"], Product 175 store_names ["Rexx"], Product
178 176
test/index_test.rb
@@ -87,7 +87,6 @@ class IndexTest &lt; Minitest::Test @@ -87,7 +87,6 @@ class IndexTest &lt; Minitest::Test
87 end 87 end
88 88
89 def test_large_value 89 def test_large_value
90 - skip if nobrainer?  
91 large_value = 1000.times.map { "hello" }.join(" ") 90 large_value = 1000.times.map { "hello" }.join(" ")
92 store [{name: "Product A", text: large_value}], Region 91 store [{name: "Product A", text: large_value}], Region
93 assert_search "product", ["Product A"], {}, Region 92 assert_search "product", ["Product A"], {}, Region
@@ -97,7 +96,6 @@ class IndexTest &lt; Minitest::Test @@ -97,7 +96,6 @@ class IndexTest &lt; Minitest::Test
97 end 96 end
98 97
99 def test_very_large_value 98 def test_very_large_value
100 - skip if nobrainer?  
101 large_value = 10000.times.map { "hello" }.join(" ") 99 large_value = 10000.times.map { "hello" }.join(" ")
102 store [{name: "Product A", text: large_value}], Region 100 store [{name: "Product A", text: large_value}], Region
103 assert_search "product", ["Product A"], {}, Region 101 assert_search "product", ["Product A"], {}, Region
test/inheritance_test.rb
1 require_relative "test_helper" 1 require_relative "test_helper"
2 2
3 class InheritanceTest < Minitest::Test 3 class InheritanceTest < Minitest::Test
4 - def setup  
5 - skip if cequel?  
6 - super  
7 - end  
8 -  
9 def test_child_reindex 4 def test_child_reindex
10 store_names ["Max"], Cat 5 store_names ["Max"], Cat
11 assert Dog.reindex 6 assert Dog.reindex
test/order_test.rb
@@ -14,8 +14,6 @@ class OrderTest &lt; Minitest::Test @@ -14,8 +14,6 @@ class OrderTest &lt; Minitest::Test
14 # TODO no longer map id to _id in Searchkick 5 14 # TODO no longer map id to _id in Searchkick 5
15 # since sorting on _id is deprecated in Elasticsearch 15 # since sorting on _id is deprecated in Elasticsearch
16 def test_id 16 def test_id
17 - skip if cequel?  
18 -  
19 store_names ["Product A", "Product B"] 17 store_names ["Product A", "Product B"]
20 product_a = Product.where(name: "Product A").first 18 product_a = Product.where(name: "Product A").first
21 product_b = Product.where(name: "Product B").first 19 product_b = Product.where(name: "Product B").first
test/reindex_test.rb
@@ -37,8 +37,6 @@ class ReindexTest &lt; Minitest::Test @@ -37,8 +37,6 @@ class ReindexTest &lt; Minitest::Test
37 end 37 end
38 38
39 def test_relation_inline 39 def test_relation_inline
40 - skip if nobrainer? || cequel?  
41 -  
42 store_names ["Product A"] 40 store_names ["Product A"]
43 store_names ["Product B", "Product C"], reindex: false 41 store_names ["Product B", "Product C"], reindex: false
44 Product.where(name: "Product B").reindex(refresh: true) 42 Product.where(name: "Product B").reindex(refresh: true)
@@ -46,8 +44,6 @@ class ReindexTest &lt; Minitest::Test @@ -46,8 +44,6 @@ class ReindexTest &lt; Minitest::Test
46 end 44 end
47 45
48 def test_relation_associations 46 def test_relation_associations
49 - skip if nobrainer? || cequel?  
50 -  
51 store_names ["Product A"] 47 store_names ["Product A"]
52 store = Store.create!(name: "Test") 48 store = Store.create!(name: "Test")
53 Product.create!(name: "Product B", store_id: store.id) 49 Product.create!(name: "Product B", store_id: store.id)
@@ -56,8 +52,6 @@ class ReindexTest &lt; Minitest::Test @@ -56,8 +52,6 @@ class ReindexTest &lt; Minitest::Test
56 end 52 end
57 53
58 def test_relation_should_index 54 def test_relation_should_index
59 - skip if nobrainer? || cequel?  
60 -  
61 skip "TODO make pass in Searchkick 5" 55 skip "TODO make pass in Searchkick 5"
62 56
63 store_names ["Product A", "Product B"] 57 store_names ["Product A", "Product B"]
test/support/cequel.rb
@@ -1,95 +0,0 @@ @@ -1,95 +0,0 @@
1 -cequel =  
2 - Cequel.connect(  
3 - host: "127.0.0.1",  
4 - port: 9042,  
5 - keyspace: "searchkick_test",  
6 - default_consistency: :all  
7 - )  
8 -cequel.logger = $logger  
9 -cequel.schema.drop! if cequel.schema.exists?  
10 -cequel.schema.create!  
11 -Cequel::Record.connection = cequel  
12 -  
13 -class Product  
14 - include Cequel::Record  
15 -  
16 - key :id, :uuid, auto: true  
17 - column :name, :text, index: true  
18 - column :store_id, :int  
19 - column :in_stock, :boolean  
20 - column :backordered, :boolean  
21 - column :orders_count, :int  
22 - column :found_rate, :decimal  
23 - column :price, :int  
24 - column :color, :text  
25 - column :latitude, :decimal  
26 - column :longitude, :decimal  
27 - column :description, :text  
28 - column :alt_description, :text  
29 - column :created_at, :timestamp  
30 -end  
31 -  
32 -class Store  
33 - include Cequel::Record  
34 -  
35 - key :id, :timeuuid, auto: true  
36 - column :name, :text  
37 -  
38 - # has issue with id serialization  
39 - def search_data  
40 - {  
41 - name: name  
42 - }  
43 - end  
44 -end  
45 -  
46 -class Region  
47 - include Cequel::Record  
48 -  
49 - key :id, :timeuuid, auto: true  
50 - column :name, :text  
51 - column :text, :text  
52 -end  
53 -  
54 -class Speaker  
55 - include Cequel::Record  
56 -  
57 - key :id, :timeuuid, auto: true  
58 - column :name, :text  
59 -end  
60 -  
61 -class Animal  
62 - include Cequel::Record  
63 -  
64 - key :id, :timeuuid, auto: true  
65 - column :name, :text  
66 -  
67 - # has issue with id serialization  
68 - def search_data  
69 - {  
70 - name: name  
71 - }  
72 - end  
73 -end  
74 -  
75 -class Dog < Animal  
76 -end  
77 -  
78 -class Cat < Animal  
79 -end  
80 -  
81 -class Sku  
82 - include Cequel::Record  
83 -  
84 - key :id, :uuid  
85 - column :name, :text  
86 -end  
87 -  
88 -class Song  
89 - include Cequel::Record  
90 -  
91 - key :id, :timeuuid, auto: true  
92 - column :name, :text  
93 -end  
94 -  
95 -[Product, Store, Region, Speaker, Animal, Sku, Song].each(&:synchronize_schema)  
test/support/nobrainer.rb
@@ -1,73 +0,0 @@ @@ -1,73 +0,0 @@
1 -NoBrainer.configure do |config|  
2 - config.app_name = :searchkick  
3 - config.environment = :test  
4 -end  
5 -  
6 -class Product  
7 - include NoBrainer::Document  
8 - include NoBrainer::Document::Timestamps  
9 -  
10 - field :id, type: Object  
11 - field :name, type: Text  
12 - field :in_stock, type: Boolean  
13 - field :backordered, type: Boolean  
14 - field :orders_count, type: Integer  
15 - field :found_rate  
16 - field :price, type: Integer  
17 - field :color, type: String  
18 - field :latitude  
19 - field :longitude  
20 - field :description, type: String  
21 - field :alt_description, type: String  
22 -  
23 - belongs_to :store, validates: false  
24 -end  
25 -  
26 -class Store  
27 - include NoBrainer::Document  
28 -  
29 - field :id, type: Object  
30 - field :name, type: String  
31 -end  
32 -  
33 -class Region  
34 - include NoBrainer::Document  
35 -  
36 - field :id, type: Object  
37 - field :name, type: String  
38 - field :text, type: Text  
39 -end  
40 -  
41 -class Speaker  
42 - include NoBrainer::Document  
43 -  
44 - field :id, type: Object  
45 - field :name, type: String  
46 -end  
47 -  
48 -class Animal  
49 - include NoBrainer::Document  
50 -  
51 - field :id, type: Object  
52 - field :name, type: String  
53 -end  
54 -  
55 -class Dog < Animal  
56 -end  
57 -  
58 -class Cat < Animal  
59 -end  
60 -  
61 -class Sku  
62 - include NoBrainer::Document  
63 -  
64 - field :id, type: String  
65 - field :name, type: String  
66 -end  
67 -  
68 -class Song  
69 - include NoBrainer::Document  
70 -  
71 - field :id, type: Object  
72 - field :name, type: String  
73 -end  
test/test_helper.rb
@@ -2,7 +2,6 @@ require &quot;bundler/setup&quot; @@ -2,7 +2,6 @@ require &quot;bundler/setup&quot;
2 Bundler.require(:default) 2 Bundler.require(:default)
3 require "minitest/autorun" 3 require "minitest/autorun"
4 require "minitest/pride" 4 require "minitest/pride"
5 -require "active_support/core_ext" if defined?(NoBrainer)  
6 require "active_support/notifications" 5 require "active_support/notifications"
7 6
8 ENV["RACK_ENV"] = "test" 7 ENV["RACK_ENV"] = "test"
@@ -47,10 +46,6 @@ ActiveSupport::LogSubscriber.logger = ActiveSupport::Logger.new(STDOUT) if ENV[&quot; @@ -47,10 +46,6 @@ ActiveSupport::LogSubscriber.logger = ActiveSupport::Logger.new(STDOUT) if ENV[&quot;
47 46
48 if defined?(Mongoid) 47 if defined?(Mongoid)
49 require_relative "support/mongoid" 48 require_relative "support/mongoid"
50 -elsif defined?(NoBrainer)  
51 - require_relative "support/nobrainer"  
52 -elsif defined?(Cequel)  
53 - require_relative "support/cequel"  
54 else 49 else
55 require_relative "support/activerecord" 50 require_relative "support/activerecord"
56 end 51 end
@@ -147,14 +142,6 @@ class Minitest::Test @@ -147,14 +142,6 @@ class Minitest::Test
147 defined?(ActiveRecord) 142 defined?(ActiveRecord)
148 end 143 end
149 144
150 - def nobrainer?  
151 - defined?(NoBrainer)  
152 - end  
153 -  
154 - def cequel?  
155 - defined?(Cequel)  
156 - end  
157 -  
158 def default_model 145 def default_model
159 Product 146 Product
160 end 147 end
test/where_test.rb
@@ -15,14 +15,11 @@ class WhereTest &lt; Minitest::Test @@ -15,14 +15,11 @@ class WhereTest &lt; Minitest::Test
15 assert_search "product", ["Product A"], where: {user_ids: 2} 15 assert_search "product", ["Product A"], where: {user_ids: 2}
16 assert_search "product", ["Product A", "Product C"], where: {user_ids: [2, 3]} 16 assert_search "product", ["Product A", "Product C"], where: {user_ids: [2, 3]}
17 17
18 - # due to precision  
19 - unless cequel?  
20 - # date  
21 - assert_search "product", ["Product A"], where: {created_at: {gt: now - 1}}  
22 - assert_search "product", ["Product A", "Product B"], where: {created_at: {gte: now - 1}}  
23 - assert_search "product", ["Product D"], where: {created_at: {lt: now - 2}}  
24 - assert_search "product", ["Product C", "Product D"], where: {created_at: {lte: now - 2}}  
25 - end 18 + # date
  19 + assert_search "product", ["Product A"], where: {created_at: {gt: now - 1}}
  20 + assert_search "product", ["Product A", "Product B"], where: {created_at: {gte: now - 1}}
  21 + assert_search "product", ["Product D"], where: {created_at: {lt: now - 2}}
  22 + assert_search "product", ["Product C", "Product D"], where: {created_at: {lte: now - 2}}
26 23
27 # integer 24 # integer
28 assert_search "product", ["Product A"], where: {store_id: {lt: 2}} 25 assert_search "product", ["Product A"], where: {store_id: {lt: 2}}