forty_facets 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83edd5ef19658c58ba68e8a0e45a01f84e03703f
|
4
|
+
data.tar.gz: 0134b19f051971d1cdba2aa1009517a1b61e60b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 342c89c8336bfdc51ccbc487ccd30d1eaa4de7caf0c2617d6d6da86291326bfd9d41c9a3dae0f0e4cee46988a16084f633b99bdab04428d79b5e6a2e77303dfe
|
7
|
+
data.tar.gz: 74d86c743767e2a2f76a3d442e3ea60c3985f385ba6c91dd8e5a15fdefa5535381ebb3dd482dc46addbc66011e381f0e3aaff145691f8b17f0031129fc18fcaa
|
data/README.md
CHANGED
@@ -53,9 +53,14 @@ class HomeController < ApplicationController
|
|
53
53
|
class MovieSearch < FortyFacets::FacetSearch
|
54
54
|
model 'Movie' # which model to search for
|
55
55
|
text :title # filter by a generic string entered by the user
|
56
|
+
range :price, name: 'Price' # filter by ranges for decimal fields
|
56
57
|
facet :genre, name: 'Genre' # generate a filter with all values of 'genre' occuring in the result
|
57
58
|
facet :year, name: 'Releaseyear', order: :year # additionally oder values in the year field
|
58
59
|
facet :studio, name: 'Studio', order: :name
|
60
|
+
|
61
|
+
orders 'Title' => :title,
|
62
|
+
'price, cheap first' => "price asc",
|
63
|
+
'price, expensive first' => {price: :desc, title: :desc}
|
59
64
|
end
|
60
65
|
|
61
66
|
def index
|
@@ -27,7 +27,7 @@ module FortyFacets
|
|
27
27
|
|
28
28
|
def facet
|
29
29
|
my_column = association.association_foreign_key
|
30
|
-
counts = without.result.select("#{my_column} as foreign_id, count(#{my_column}) as occurrences").group(my_column)
|
30
|
+
counts = without.result.reorder('').select("#{my_column} as foreign_id, count(#{my_column}) as occurrences").group(my_column)
|
31
31
|
entities_by_id = klass.find(counts.map(&:foreign_id)).group_by(&:id)
|
32
32
|
facet = counts.inject([]) do |sum, count|
|
33
33
|
facet_entity = entities_by_id[count.foreign_id].first
|
@@ -17,7 +17,7 @@ module FortyFacets
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def absolute_interval
|
20
|
-
@abosultes ||= without.result.select("min(#{filter_definition.model_field}) as min, max(#{filter_definition.model_field}) as max").first
|
20
|
+
@abosultes ||= without.result.reorder('').select("min(#{filter_definition.model_field}) as min, max(#{filter_definition.model_field}) as max").first
|
21
21
|
end
|
22
22
|
|
23
23
|
def absolute_min
|
data/lib/forty_facets/version.rb
CHANGED