Commit b1d08c1c81f806871319775a64c62cd322c64487
1 parent
bcd5cd44
Exists in
master
and in
29 other branches
solr-plugin: port to rails 3
Showing
6 changed files
with
12 additions
and
56 deletions
Show diff stats
plugins/solr/config/solr.yml.dist
... | ... | @@ -9,18 +9,18 @@ |
9 | 9 | production: |
10 | 10 | url: http://127.0.0.1:8983/solr |
11 | 11 | jvm_options: -server -Xmx192M -Xms64M |
12 | - timeout: 0 | |
12 | + timeout: 600 | |
13 | 13 | data_path: /var/lib/noosfero-data/solr/index |
14 | 14 | |
15 | 15 | development: |
16 | 16 | url: http://0.0.0.0:8982/solr |
17 | 17 | jvm_options: -server -Xmx128M -Xms16M |
18 | - timeout: 0 | |
18 | + timeout: 600 | |
19 | 19 | |
20 | 20 | test: &TEST |
21 | 21 | url: http://0.0.0.0:8981/solr |
22 | 22 | jvm_options: -server -Xmx128M -Xms16M |
23 | - timeout: 0 | |
23 | + timeout: 600 | |
24 | 24 | |
25 | 25 | cucumber: |
26 | 26 | <<: *TEST | ... | ... |
plugins/solr/install.rb
plugins/solr/lib/ext/product.rb
... | ... | @@ -27,7 +27,8 @@ class Product |
27 | 27 | {:name => {:type => :text, :boost => 2.0}}, |
28 | 28 | {:description => :text}, {:category_full_name => :text}, |
29 | 29 | # filtered fields |
30 | - {:solr_plugin_public => :boolean}, {:environment_id => :integer}, | |
30 | + {:solr_plugin_public => :boolean}, | |
31 | + {:environment_id => :integer}, {:profile_id => :integer}, | |
31 | 32 | {:enabled => :boolean}, {:solr_plugin_category_filter => :integer}, |
32 | 33 | # ordered/query-boosted fields |
33 | 34 | {:solr_plugin_price_sortable => :decimal}, {:solr_plugin_name_sortable => :string}, | ... | ... |
plugins/solr/lib/ext/profile.rb
... | ... | @@ -42,7 +42,7 @@ class Profile |
42 | 42 | handle_asynchronously :solr_save |
43 | 43 | handle_asynchronously :solr_destroy |
44 | 44 | |
45 | - class_inheritable_accessor :solr_plugin_extra_index_methods | |
45 | + class_attribute :solr_plugin_extra_index_methods | |
46 | 46 | self.solr_plugin_extra_index_methods = [] |
47 | 47 | |
48 | 48 | def solr_plugin_extra_data_for_index | ... | ... |
plugins/solr/lib/solr_plugin.rb
... | ... | @@ -33,8 +33,8 @@ class SolrPlugin < Noosfero::Plugin |
33 | 33 | |
34 | 34 | solr_options = solr_options(class_asset(klass), category) |
35 | 35 | solr_options[:filter_queries] ||= [] |
36 | - solr_options[:filter_queries] += scopes_to_solr_filters scope, klass, options | |
37 | - solr_options.merge! products_options(user) if klass == Product and empty_query | |
36 | + solr_options[:filter_queries] += scopes_to_solr_options scope, klass, options | |
37 | + solr_options.merge! products_options(user) if asset == :products and empty_query | |
38 | 38 | solr_options.merge! options.except(:category, :filter) |
39 | 39 | |
40 | 40 | scope.find_by_contents query, paginate_options, solr_options |
... | ... | @@ -42,14 +42,14 @@ class SolrPlugin < Noosfero::Plugin |
42 | 42 | |
43 | 43 | protected |
44 | 44 | |
45 | - def scopes_to_solr_filters scope, klass = nil, options = {} | |
45 | + def scopes_to_solr_options scope, klass = nil, options = {} | |
46 | 46 | filter_queries = [] |
47 | 47 | klass ||= scope.base_class |
48 | 48 | solr_fields = klass.configuration[:solr_fields].keys |
49 | 49 | scopes_applied = scope.scopes_applied.dup rescue [] #rescue association and class direct filtering |
50 | 50 | |
51 | - scope.current_scoped_methods[:create].each do |attr, value| | |
52 | - next unless solr_fields.include? attr.to_sym | |
51 | + scope.scope_attributes.each do |attr, value| | |
52 | + raise "Non-indexed attribute '#{attr}' speficied in scope_attributes" unless solr_fields.include? attr.to_sym | |
53 | 53 | |
54 | 54 | # if the filter is present here, then prefer it |
55 | 55 | scopes_applied.reject!{ |name| name == attr.to_sym } | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/test.rake
... | ... | @@ -1,45 +0,0 @@ |
1 | - | |
2 | -desc "Default Task" | |
3 | -task :default => [:test] | |
4 | - | |
5 | -desc "Runs the unit tests" | |
6 | -task :test => "test:unit" | |
7 | - | |
8 | -namespace :test do | |
9 | - | |
10 | - task :migrate do | |
11 | - ActiveRecord::Base.logger = Logger.new(STDOUT) | |
12 | - ActiveRecord::Migrator.migrate("test/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) | |
13 | - end | |
14 | - | |
15 | - task :setup do | |
16 | - DB ||= 'sqlite' | |
17 | - puts "Using " + DB | |
18 | - %x(mysql -u#{MYSQL_USER} < #{File.dirname(__FILE__) + "/test/fixtures/db_definitions/mysql.sql"}) if DB == 'mysql' | |
19 | - | |
20 | - Rake::Task["test:migrate"].invoke | |
21 | - end | |
22 | - | |
23 | - desc 'Measures test coverage using rcov' | |
24 | - task :rcov => :setup do | |
25 | - rm_f "coverage" | |
26 | - rm_f "coverage.data" | |
27 | - rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib" | |
28 | - | |
29 | - system("#{rcov} --html #{Dir.glob('test/**/*_shoulda.rb').join(' ')}") | |
30 | - system("open coverage/index.html") if PLATFORM['darwin'] | |
31 | - end | |
32 | - | |
33 | - desc 'Runs the functional tests, testing integration with Solr' | |
34 | - Rake::TestTask.new(:functional => :setup) do |t| | |
35 | - t.pattern = "test/functional/*_test.rb" | |
36 | - t.verbose = true | |
37 | - end | |
38 | - | |
39 | - desc "Unit tests" | |
40 | - Rake::TestTask.new(:unit => :setup) do |t| | |
41 | - t.libs << 'test/unit' | |
42 | - t.pattern = "test/unit/*_shoulda.rb" | |
43 | - t.verbose = true | |
44 | - end | |
45 | -end |