Author: Braulio Bhavamitra <braulio@prout.io>
solr: remove ordering on searches
app/helpers/search_helper.rb | 4 ++-- app/models/article.rb | 5 ++--- plugins/solr/lib/ext/article.rb | 2 ++ plugins/solr/lib/ext/enterprise.rb | 2 ++ plugins/solr/lib/ext/organization.rb | 7 +++++++ plugins/solr/lib/ext/person.rb | 7 +++++++ plugins/solr/lib/ext/profile.rb | 2 ++ plugins/solr/lib/solr_plugin/base.rb | 1 +
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 1ff50c4048772b7b7c3199fb77c7f71b710bc097..32b3590b4560332558318a5439a49b173af7d752 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -8,8 +8,8 @@ def filters_options_translation @filters_options_translation ||= { :order => { - #'more_popular' => _('More popular'), - #'more_active' => _('More active'), + 'more_popular' => _('More popular'), + 'more_active' => _('More active'), 'more_recent' => _('More recent'), 'more_comments' => _('More comments') }, diff --git a/app/models/article.rb b/app/models/article.rb index 9b773043675090c39fc2bc344c484a20d134f731..a2339a5242ed6bc173e2a1cc85ae4319f3012515 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -35,8 +35,7 @@ :filename => {:label => _('Filename'), :weight => 1}, } SEARCH_FILTERS = { - :order => %w[more_recent more_comments], - #:order => %w[more_recent more_popular more_comments], + :order => %w[more_recent more_popular more_comments], :display => %w[full] } @@ -178,7 +177,7 @@ RESERVED_SLUGS = %w[ about activities - ] + ] def valid_slug errors.add(:title, _('is not available as article name.')) unless Article.is_slug_available?(slug) diff --git a/plugins/solr/lib/ext/article.rb b/plugins/solr/lib/ext/article.rb index c75aa084a3285e6da1c1044af819420f8f01e1b6..f72cc773ec16dd4c0793c771d223d5923ea4a3c2 100644 --- a/plugins/solr/lib/ext/article.rb +++ b/plugins/solr/lib/ext/article.rb @@ -4,6 +4,8 @@ ActiveSupport.run_load_hooks :solr_article class Article + SEARCH_FILTERS[:order] = [] + # use for internationalizable human type names in search facets # reimplement on subclasses def self.type_name diff --git a/plugins/solr/lib/ext/enterprise.rb b/plugins/solr/lib/ext/enterprise.rb index d26f83ab64bf429d1288a693e07b810a1e0c2527..fc8611fddb25a36016a030cb2cdef87e2e0d8205 100644 --- a/plugins/solr/lib/ext/enterprise.rb +++ b/plugins/solr/lib/ext/enterprise.rb @@ -5,6 +5,8 @@ ActiveSupport.run_load_hooks :solr_enterprise class Enterprise + SEARCH_FILTERS[:order] = [] + after_save_reindex [:products], with: :delayed_job extend SolrPlugin::ActsAsSearchable diff --git a/plugins/solr/lib/ext/organization.rb b/plugins/solr/lib/ext/organization.rb new file mode 100644 index 0000000000000000000000000000000000000000..a99223e875f374441dcea2cdd894a822d514d190 --- /dev/null +++ b/plugins/solr/lib/ext/organization.rb @@ -0,0 +1,7 @@ +require_dependency 'organization' + +class Organization + + SEARCH_FILTERS[:order] = [] + +end diff --git a/plugins/solr/lib/ext/person.rb b/plugins/solr/lib/ext/person.rb new file mode 100644 index 0000000000000000000000000000000000000000..682ebaad5d3e6efb89470b6ee654088bda3a95fb --- /dev/null +++ b/plugins/solr/lib/ext/person.rb @@ -0,0 +1,7 @@ +require_dependency 'person' + +class Person + + SEARCH_FILTERS[:order] = [] + +end diff --git a/plugins/solr/lib/ext/profile.rb b/plugins/solr/lib/ext/profile.rb index 60e000605008abc939598396ed62516ca9904f3a..d4726cdf10ea8e204da8b04a009dd16cbc7b8a70 100644 --- a/plugins/solr/lib/ext/profile.rb +++ b/plugins/solr/lib/ext/profile.rb @@ -4,6 +4,8 @@ ActiveSupport.run_load_hooks :solr_profile class Profile + SEARCH_FILTERS[:order] = [] + # use for internationalizable human type names in search facets # reimplement on subclasses def self.type_name diff --git a/plugins/solr/lib/solr_plugin/base.rb b/plugins/solr/lib/solr_plugin/base.rb index 255de877d2d1fc107f293c33a387b15ff53d438f..b227f170d3f44a1e447056d244a0d2e82713c98e 100644 --- a/plugins/solr/lib/solr_plugin/base.rb +++ b/plugins/solr/lib/solr_plugin/base.rb @@ -163,6 +163,7 @@ end scopes_applied.each do |name| #next if name.to_s == options[:filter].to_s + next if name.to_s == context.instance_variable_get(:@order) # not yet supported as it involves ordering next if name.to_s.in? klass::SEARCH_FILTERS[:order]