Changeset 248
- Timestamp:
- 10/01/07 14:50:29 (1 year ago)
- Files:
-
- trunk/demo/test/unit/content_test.rb (modified) (2 diffs)
- trunk/plugin/acts_as_ferret/lib/class_methods.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/ferret_extensions.rb (modified) (2 diffs)
- trunk/plugin/acts_as_ferret/lib/local_index.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/demo/test/unit/content_test.rb
r246 r248 26 26 ContentBase.find(:all).each { |c| c.destroy } 27 27 Comment.find(:all).each { |c| c.destroy } 28 end 29 30 def test_include_option 31 assert_equal 1, Content.find_with_ferret('description', {}, :include => :comments).size 28 32 end 29 33 … … 181 185 assert_equal 6, records.size 182 186 end 187 end 188 189 def test_bulk_index_no_optimize 190 Content.disable_ferret do 191 more_contents 192 end 193 194 assert Content.find_with_ferret('title').empty? 195 min = Content.find(:all, :order => 'id asc').first.id 196 Content.bulk_index(min, min+1, min+2, min+3, min+4, min+6, :optimize => false) 197 assert_equal 6, Content.find_with_ferret('title').size 183 198 end 184 199 trunk/plugin/acts_as_ferret/lib/class_methods.rb
r247 r248 38 38 # indexing jobs i.e. after modifying a lot of records with Ferret disabled. 39 39 def bulk_index(*ids) 40 options = Hash === ids.last ? ids.pop : {} 40 41 ids = ids.first if ids.size == 1 && ids.first.is_a?(Enumerable) 41 aaf_index.bulk_index(ids )42 aaf_index.bulk_index(ids, options) 42 43 end 43 44 trunk/plugin/acts_as_ferret/lib/ferret_extensions.rb
r239 r248 55 55 end 56 56 57 def bulk_index(model, ids) 57 def bulk_index(model, ids, options = {}) 58 options.reverse_merge! :optimize => true 58 59 orig_flush = @auto_flush 59 60 @auto_flush = false … … 64 65 bulk_indexer.index_records(records, offset) 65 66 end 67 logger.info 'finishing bulk index...' 66 68 flush 67 optimize 69 if options[:optimize] 70 logger.info 'optimizing...' 71 optimize 72 end 68 73 @auto_flush = orig_flush 69 74 end trunk/plugin/acts_as_ferret/lib/local_index.rb
r247 r248 63 63 end 64 64 65 def bulk_index(ids )66 ferret_index.bulk_index(aaf_configuration[:class_name].constantize, ids )65 def bulk_index(ids, options) 66 ferret_index.bulk_index(aaf_configuration[:class_name].constantize, ids, options) 67 67 end 68 68
