collate 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/collate/active_record_extension.rb +26 -12
- data/lib/collate/filter.rb +2 -2
- data/lib/collate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd2490c72305c02d1b4673b598db71192258ebf1
|
4
|
+
data.tar.gz: ac8e9482583d628e035304c749afc101cb4221ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fca90116c85619627ae10df80d8e823cbd7fcba7f27fc972c39a184df17117961fefa372e5a46884fedcee3526f5e6b09995f2bd02b4af9f03b3d9e863c16c8
|
7
|
+
data.tar.gz: bfe21191da02ad18e9dfdcf1ed27c6eb30f5223215274aa9c948f5f4f1852cddb039844bc236fd5269072efda06944a56f8e79b1326b91ee14b8beacf431a3cf
|
@@ -95,6 +95,30 @@ module Collate
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def apply_filter ar_rel, filter, param_value
|
98
|
+
ar_rel, ar_method, query_string, filter_value = if filter.field.is_a?(Array)
|
99
|
+
full_query_strings = []
|
100
|
+
full_filter_values = []
|
101
|
+
|
102
|
+
filter.field.each do |filter_field|
|
103
|
+
ar_rel, ar_method, query_string, filter_value = get_filter_data ar_rel, filter_field, filter, param_value
|
104
|
+
|
105
|
+
full_query_strings << query_string
|
106
|
+
full_filter_values << filter_value
|
107
|
+
end
|
108
|
+
|
109
|
+
[ar_rel, ar_method, full_query_strings.join(' OR '), full_filter_values.flatten]
|
110
|
+
else
|
111
|
+
get_filter_data ar_rel, filter.field.dup, filter, param_value
|
112
|
+
end
|
113
|
+
|
114
|
+
ar_rel = if query_string.include?('?')
|
115
|
+
ar_rel.send(ar_method, query_string, *filter_value)
|
116
|
+
else
|
117
|
+
ar_rel.send(ar_method, query_string)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_filter_data ar_rel, filter_field, filter, param_value
|
98
122
|
filter_value = if param_value.duplicable?
|
99
123
|
param_value.dup
|
100
124
|
else
|
@@ -141,9 +165,7 @@ module Collate
|
|
141
165
|
|
142
166
|
ar_rel = ar_rel.group(filter.grouping) if filter.grouping
|
143
167
|
|
144
|
-
|
145
|
-
|
146
|
-
field_query = filter.field
|
168
|
+
field_query = filter_field
|
147
169
|
|
148
170
|
filter.field_transformations.each do |ft|
|
149
171
|
transformation = ft
|
@@ -230,15 +252,7 @@ module Collate
|
|
230
252
|
query_string = filter_value.length.times.collect{query_string}.join(' OR ') if filter.or
|
231
253
|
query_string = "NOT(#{query_string})" if filter.not
|
232
254
|
|
233
|
-
ar_rel
|
234
|
-
if filter.or
|
235
|
-
ar_rel.send(ar_method, query_string, *filter_value)
|
236
|
-
else
|
237
|
-
ar_rel.send(ar_method, query_string, filter_value)
|
238
|
-
end
|
239
|
-
else
|
240
|
-
ar_rel.send(ar_method, query_string)
|
241
|
-
end
|
255
|
+
[ar_rel, ar_method, query_string, filter_value]
|
242
256
|
end
|
243
257
|
|
244
258
|
end
|
data/lib/collate/filter.rb
CHANGED
@@ -8,7 +8,7 @@ module Collate
|
|
8
8
|
|
9
9
|
attr_accessor :field, :operator, :base_model_table_name, :field_transformations, :label,
|
10
10
|
:component, :joins, :value_transformations, :grouping, :html_id, :having,
|
11
|
-
:joins_prefix, :not, :or
|
11
|
+
:joins_prefix, :not, :or
|
12
12
|
|
13
13
|
def initialize(field, opt={})
|
14
14
|
opt.each do |f, value|
|
@@ -112,7 +112,7 @@ module Collate
|
|
112
112
|
key += VALUE_TRANSFORMATIONS.index(transformation).to_s
|
113
113
|
end
|
114
114
|
|
115
|
-
"{#{key}}#{field}"
|
115
|
+
"{#{key}}#{field.to_s.gsub('[','').gsub(']','')}"
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
data/lib/collate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Page
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-02-
|
12
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|