sunspot_rails 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -187,7 +187,7 @@ module Sunspot #:nodoc:
187
187
  #
188
188
  # Add/update all existing records in the Solr index. The
189
189
  # +batch_size+ argument specifies how many records to load out of the
190
- # database at a time. The default batch size is 500; if nil is passed,
190
+ # database at a time. The default batch size is 50; if nil is passed,
191
191
  # records will not be indexed in batches. By default, a commit is issued
192
192
  # after each batch; passing +false+ for +batch_commit+ will disable
193
193
  # this, and only issue a commit at the end of the process. If associated
@@ -197,7 +197,7 @@ module Sunspot #:nodoc:
197
197
  # ==== Options (passed as a hash)
198
198
  #
199
199
  # batch_size<Integer>:: Batch size with which to load records. Passing
200
- # 'nil' will skip batches. Default is 500.
200
+ # 'nil' will skip batches. Default is 50.
201
201
  # batch_commit<Boolean>:: Flag signalling if a commit should be done after
202
202
  # after each batch is indexed, default is 'true'
203
203
  # include<Mixed>:: include option to be passed to the ActiveRecord find,
@@ -210,13 +210,13 @@ module Sunspot #:nodoc:
210
210
  #
211
211
  # ==== Examples
212
212
  #
213
- # # index in batches of 500, commit after each
213
+ # # index in batches of 50, commit after each
214
214
  # Post.index
215
215
  #
216
216
  # # index all rows at once, then commit
217
217
  # Post.index(:batch_size => nil)
218
218
  #
219
- # # index in batches of 500, commit when all batches complete
219
+ # # index in batches of 50, commit when all batches complete
220
220
  # Post.index(:batch_commit => false)
221
221
  #
222
222
  # # include the associated +author+ object when loading to index
@@ -224,18 +224,20 @@ module Sunspot #:nodoc:
224
224
  #
225
225
  def solr_index(opts={})
226
226
  options = {
227
- :batch_size => 500,
227
+ :batch_size => 50,
228
228
  :batch_commit => true,
229
229
  :include => self.sunspot_options[:include],
230
230
  :first_id => 0
231
231
  }.merge(opts)
232
232
 
233
233
  if options[:batch_size]
234
+ counter = 0
234
235
  find_in_batches(:include => options[:include], :batch_size => options[:batch_size]) do |records|
235
236
  solr_benchmark options[:batch_size], counter do
236
237
  Sunspot.index(records)
237
238
  end
238
239
  Sunspot.commit if options[:batch_commit]
240
+ counter += 1
239
241
  end
240
242
  Sunspot.commit unless options[:batch_commit]
241
243
  else
@@ -27,7 +27,7 @@ namespace :sunspot do
27
27
  desc "Reindex all solr models that are located in your application's models directory."
28
28
  # This task depends on the standard Rails file naming \
29
29
  # conventions, in that the file name matches the defined class name. \
30
- # By default the indexing system works in batches of 500 records, you can \
30
+ # By default the indexing system works in batches of 50 records, you can \
31
31
  # set your own value for this by using the batch_size argument. You can \
32
32
  # also optionally define a list of models to separated by a forward slash '/'
33
33
  #
@@ -1,5 +1,5 @@
1
1
  module Sunspot
2
2
  module Rails
3
- VERSION = '1.2.0'
3
+ VERSION = '1.2.1'
4
4
  end
5
5
  end
data/spec/model_spec.rb CHANGED
@@ -301,56 +301,6 @@ describe 'ActiveRecord mixin' do
301
301
  end
302
302
 
303
303
  describe "when using batches" do
304
-
305
- it "should use the default options" do
306
- Post.should_receive(:all).with do |params|
307
- params[:limit].should == 500
308
- params[:include].should == []
309
- params[:conditions].should == ['posts.id > ?', 0]
310
- params[:order].should == 'posts.id'
311
- end.and_return(@posts)
312
- Post.reindex
313
- end
314
-
315
- it "should set the conditions using the overridden table attributes" do
316
- @posts = Array.new(2) { Author.create }
317
- Author.should_receive(:all).with do |params|
318
- params[:conditions].should == ['writers.writer_id > ?', 0]
319
- params[:order].should == 'writers.writer_id'
320
- end.and_return(@posts)
321
- Author.reindex
322
- end
323
-
324
- it "should count the number of records to index" do
325
- Post.should_receive(:count).and_return(10)
326
- Post.reindex
327
- end
328
-
329
- it "should override the batch_size" do
330
- Post.should_receive(:all).with do |params|
331
- params[:limit].should == 20
332
- @posts
333
- end.and_return(@posts)
334
- Post.reindex(:batch_size => 20)
335
- end
336
-
337
- it "should set the include option" do
338
- Post.should_receive(:all).with do |params|
339
- params[:include].should == [{:author => :address}]
340
- @posts
341
- end.and_return(@posts)
342
- Post.reindex(:include => [{:author => :address}])
343
- end
344
-
345
- it "should set the include option from the searchable options" do
346
- @blogs = Array.new(2) { Blog.create }
347
- Blog.should_receive(:all).with do |params|
348
- params[:include].should == [{ :posts => :author }, :comments]
349
- @blogs
350
- end.and_return(@blogs)
351
- Blog.reindex
352
- end
353
-
354
304
  it "should commit after indexing each batch" do
355
305
  Sunspot.should_receive(:commit).twice
356
306
  Post.reindex(:batch_size => 1)
@@ -360,7 +310,6 @@ describe 'ActiveRecord mixin' do
360
310
  Sunspot.should_receive(:commit).once
361
311
  Post.reindex(:batch_commit => false)
362
312
  end
363
-
364
313
  end
365
314
  end
366
315
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
7
  - 2
9
- - 0
10
- version: 1.2.0
8
+ - 1
9
+ version: 1.2.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Mat Brown
@@ -23,7 +22,7 @@ autorequire:
23
22
  bindir: bin
24
23
  cert_chain: []
25
24
 
26
- date: 2010-12-29 00:00:00 -05:00
25
+ date: 2010-12-29 00:00:00 -07:00
27
26
  default_executable:
28
27
  dependencies:
29
28
  - !ruby/object:Gem::Dependency
@@ -34,44 +33,54 @@ dependencies:
34
33
  requirements:
35
34
  - - "="
36
35
  - !ruby/object:Gem::Version
37
- hash: 31
38
36
  segments:
39
37
  - 1
40
38
  - 2
41
- - 0
42
- version: 1.2.0
39
+ - 1
40
+ version: 1.2.1
43
41
  type: :runtime
44
42
  version_requirements: *id001
45
43
  - !ruby/object:Gem::Dependency
46
- name: rspec
44
+ name: nokogiri
47
45
  prerelease: false
48
46
  requirement: &id002 !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :runtime
55
+ version_requirements: *id002
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ prerelease: false
59
+ requirement: &id003 !ruby/object:Gem::Requirement
49
60
  none: false
50
61
  requirements:
51
62
  - - ~>
52
63
  - !ruby/object:Gem::Version
53
- hash: 11
54
64
  segments:
55
65
  - 1
56
66
  - 2
57
67
  version: "1.2"
58
68
  type: :development
59
- version_requirements: *id002
69
+ version_requirements: *id003
60
70
  - !ruby/object:Gem::Dependency
61
71
  name: rspec-rails
62
72
  prerelease: false
63
- requirement: &id003 !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
64
74
  none: false
65
75
  requirements:
66
76
  - - ~>
67
77
  - !ruby/object:Gem::Version
68
- hash: 11
69
78
  segments:
70
79
  - 1
71
80
  - 2
72
81
  version: "1.2"
73
82
  type: :development
74
- version_requirements: *id003
83
+ version_requirements: *id004
75
84
  description: |
76
85
  Sunspot::Rails is an extension to the Sunspot library for Solr search.
77
86
  Sunspot::Rails adds integration between Sunspot and ActiveRecord, including
@@ -88,47 +97,47 @@ extensions: []
88
97
  extra_rdoc_files: []
89
98
 
90
99
  files:
91
- - VERSION.yml
92
- - TESTING.md
93
- - Rakefile
94
- - MIT-LICENSE
95
- - LICENSE
96
100
  - History.txt
97
- - TODO
101
+ - LICENSE
102
+ - MIT-LICENSE
103
+ - Rakefile
98
104
  - README.rdoc
99
- - lib/sunspot_rails.rb
100
- - lib/sunspot/rails/solr_logging.rb
101
- - lib/sunspot/rails/railtie.rb
102
- - lib/sunspot/rails/version.rb
103
- - lib/sunspot/rails/server.rb
105
+ - TESTING.md
106
+ - TODO
107
+ - VERSION.yml
108
+ - lib/generators/sunspot_rails/install/install_generator.rb
109
+ - lib/generators/sunspot_rails/install/templates/config/sunspot.yml
110
+ - lib/generators/sunspot_rails.rb
111
+ - lib/sunspot/rails/adapters.rb
104
112
  - lib/sunspot/rails/configuration.rb
113
+ - lib/sunspot/rails/init.rb
114
+ - lib/sunspot/rails/railtie.rb
105
115
  - lib/sunspot/rails/request_lifecycle.rb
106
- - lib/sunspot/rails/stub_session_proxy.rb
116
+ - lib/sunspot/rails/searchable.rb
117
+ - lib/sunspot/rails/server.rb
118
+ - lib/sunspot/rails/solr_logging.rb
107
119
  - lib/sunspot/rails/spec_helper.rb
120
+ - lib/sunspot/rails/stub_session_proxy.rb
108
121
  - lib/sunspot/rails/tasks.rb
109
- - lib/sunspot/rails/searchable.rb
110
- - lib/sunspot/rails/adapters.rb
111
- - lib/sunspot/rails/init.rb
122
+ - lib/sunspot/rails/version.rb
112
123
  - lib/sunspot/rails.rb
113
- - lib/generators/sunspot_rails.rb
114
- - lib/generators/sunspot_rails/install/install_generator.rb
115
- - lib/generators/sunspot_rails/install/templates/config/sunspot.yml
116
- - dev_tasks/spec.rake
117
- - dev_tasks/release.rake
124
+ - lib/sunspot_rails.rb
118
125
  - dev_tasks/rdoc.rake
126
+ - dev_tasks/release.rake
127
+ - dev_tasks/spec.rake
119
128
  - dev_tasks/todo.rake
120
- - generators/sunspot/templates/sunspot.yml
121
129
  - generators/sunspot/sunspot_generator.rb
130
+ - generators/sunspot/templates/sunspot.yml
122
131
  - install.rb
123
- - spec/session_spec.rb
124
- - spec/schema.rb
125
132
  - spec/configuration_spec.rb
126
133
  - spec/model_lifecycle_spec.rb
127
- - spec/spec_helper.rb
128
- - spec/stub_session_proxy_spec.rb
129
- - spec/request_lifecycle_spec.rb
130
134
  - spec/model_spec.rb
135
+ - spec/request_lifecycle_spec.rb
136
+ - spec/schema.rb
131
137
  - spec/server_spec.rb
138
+ - spec/session_spec.rb
139
+ - spec/spec_helper.rb
140
+ - spec/stub_session_proxy_spec.rb
132
141
  has_rdoc: true
133
142
  homepage: http://github.com/outoftime/sunspot_rails
134
143
  licenses: []
@@ -143,7 +152,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
152
  requirements:
144
153
  - - ">="
145
154
  - !ruby/object:Gem::Version
146
- hash: 3
147
155
  segments:
148
156
  - 0
149
157
  version: "0"
@@ -152,7 +160,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
160
  requirements:
153
161
  - - ">="
154
162
  - !ruby/object:Gem::Version
155
- hash: 3
156
163
  segments:
157
164
  - 0
158
165
  version: "0"