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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109687180e0ee8bc369a74c9884430021f167fd43694b7ee43a4cdd486846af6
|
4
|
+
data.tar.gz: ec7bd149ecbdb47adb470f7b88da290f59247544034de5fb1184104426c95aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
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
|
-
@
|
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
|
-
|
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
|
-
|
29
|
+
@values ||= begin
|
30
30
|
joined_table = facets.model_table_name.to_sym
|
31
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|