faceted_search 3.5.5 → 3.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 553d3617dd9ce61d6c40ee05bbb892fe015d92154858d8d94b9b1f17fa3c0bbe
4
- data.tar.gz: 23c554467eea8e4495d8bcc4e3b32bbd7a9770be3eb19e27d10c13503b4bb9d3
3
+ metadata.gz: 109687180e0ee8bc369a74c9884430021f167fd43694b7ee43a4cdd486846af6
4
+ data.tar.gz: ec7bd149ecbdb47adb470f7b88da290f59247544034de5fb1184104426c95aac
5
5
  SHA512:
6
- metadata.gz: 7f030a78d48278f60d0a9c6f2c45663d4089d4745ef5fc212a10d8d41e21f5680529ca2c41447f8db0027fd23e60ecde3a3a606070d25887b9e8315a6d21c885
7
- data.tar.gz: 29a04e3c793429cd53d1496da956f954f73ad9049cdf7866cae122e54a2695b5d3578cffded28ba0a3b04a25ea50aab18765c7cce1f9dfc85f9bd52ac113829a
6
+ metadata.gz: 0a1cd9a1f7ad2ce69a778b7cef0c826ad97b277b6700f5973e5a7479c23c9a35d11fd64938bf1b21a389233520c84b974478ac33ae3c2a52cb5287fdde35dc0b
7
+ data.tar.gz: 7a9f15c607f02534ea00ddd6ad59122af8a765ba7cf4aa16459bfe207b6d07ab982250f3a0d23ebf1d3a765073b150a4aa2d26b2530cf3d4ed0206683d7060f1
@@ -36,14 +36,16 @@ module FacetedSearch
36
36
  end
37
37
 
38
38
  def results
39
- unless @results
40
- scope = @model
41
- list.each do |facet|
42
- scope = facet.add_scope(scope) unless facet.ignore_scope?
43
- end
44
- @results = scope.distinct
39
+ @results ||= results_except []
40
+ end
41
+
42
+ def results_except(*facet_names)
43
+ scope = @model
44
+ list.each do |facet|
45
+ next if facet_names.include?(facet.name) || facet.ignore_scope?
46
+ scope = facet.add_scope(scope)
45
47
  end
46
- @results
48
+ scope.distinct
47
49
  end
48
50
 
49
51
  def model_table_name
@@ -2,7 +2,11 @@ module FacetedSearch
2
2
  class Facets::Date < Facets::DefaultList
3
3
 
4
4
  def source
5
- @options[:source] || @facets.model.send(:all).pluck(name).compact.map(&:year).uniq.sort
5
+ @source ||= begin
6
+ next @options[:source] if @options[:source].present?
7
+ results = params_array.blank? ? facets.results : facets.results_except(@name)
8
+ results.send(:all).pluck(name).compact.map(&:year).uniq.sort
9
+ end
6
10
  end
7
11
 
8
12
  def order
@@ -19,11 +23,7 @@ module FacetedSearch
19
23
  end
20
24
 
21
25
  def values
22
- unless @values
23
- @values = source
24
- @values.reverse! unless order == :asc
25
- end
26
- @values
26
+ @values ||= order == :asc ? source : source.reverse
27
27
  end
28
28
  end
29
29
  end
@@ -26,11 +26,11 @@ module FacetedSearch
26
26
  # Show all values that have corresponding results with the current params.
27
27
  # This is a regular SQL inner join.
28
28
  def values
29
- unless @values
29
+ @values ||= begin
30
30
  joined_table = facets.model_table_name.to_sym
31
- @values = source.all.joins(joined_table).where(joined_table => { id: facets.results }).distinct
31
+ results = params_array.blank? ? facets.results : facets.results_except(@name)
32
+ source.all.joins(joined_table).where(joined_table => { id: results }).distinct
32
33
  end
33
- @values
34
34
  end
35
35
 
36
36
  def value_selected?(value)
@@ -2,6 +2,11 @@ module FacetedSearch
2
2
  class Facets::PrimitiveList < Facets::DefaultList
3
3
 
4
4
  def source
5
+ @source ||= begin
6
+ next @options[:source] if @options[:source].present?
7
+ results = params_array.compact.blank? ? facets.results : facets.results_except(@name)
8
+ results.send(:all).where("#{field} IS NOT NULL")
9
+ end
5
10
  @options[:source].where("#{field} IS NOT NULL")
6
11
  end
7
12
 
@@ -22,11 +27,10 @@ module FacetedSearch
22
27
  end
23
28
 
24
29
  def values
25
- unless @values
26
- @values = source.pluck(field).uniq.reject(&:empty?).sort
27
- @values.reverse! unless order == :asc
30
+ @values ||= begin
31
+ values = source.pluck(field).uniq.reject(&:blank?).sort
32
+ order == :asc ? values : values.reverse
28
33
  end
29
- @values
30
34
  end
31
35
  end
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module FacetedSearch
2
- VERSION = '3.5.5'
2
+ VERSION = '3.5.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faceted_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.5
4
+ version: 3.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy