forest_liana 3.0.7 → 3.1.0

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
  SHA1:
3
- metadata.gz: 68c604c785dc5716cc0d25fc8455229f17f3527f
4
- data.tar.gz: e465903c0cca6fb01b29afb9fb364992e3b94571
3
+ metadata.gz: aa10ea49b5d651340708ab73c554511cd70338c3
4
+ data.tar.gz: acb4a3b7f02ea2032edfe4522ffcb5c05e0ae8c1
5
5
  SHA512:
6
- metadata.gz: bd8e47833cb78385383c663d29d8ec7d45e459f06d5edbc2ac4423ce8243dd2d5ca197cea469beef25e03e79a6004853e5b1ef709e80df074d2465edb0bbd057
7
- data.tar.gz: 86d71299a258e38f083e67aa3fbfba77d5a87cf49922f0ff1665a2b1164351dd470b8b7feeae34f148faa36cfd0503a41630e460ecfa10fe09722a164386fea0
6
+ metadata.gz: 4c1bea91f48f1d78e93ef4ab74ed177d84193c82bc48cd632272d0dfd5e64c75d8c7031f5190c7edbdc3d9027c8a35b5eddd23a6f1b425d07c459d282a9ab9b8
7
+ data.tar.gz: c26d013d000f2c7c3eb4e9a40e086f9664e77bc426f56b106fe8c878b618421d17ed9e242c200b9ed33c25ba7fa35a8213527270c43708e7e0a72ec4b05fcd66
@@ -17,9 +17,8 @@ module ForestLiana
17
17
  @tables_associated_to_relations_name =
18
18
  ForestLiana::QueryHelper.get_tables_associated_to_relations_name(@resource)
19
19
  @records = search_param
20
- @records = filter_param
21
20
  @records = has_many_filter
22
- @records = belongs_to_filter
21
+ @records = belongs_to_and_params_filter
23
22
 
24
23
  if @search
25
24
  ForestLiana.schema_for_resource(@resource).fields.each do |field|
@@ -37,6 +36,11 @@ module ForestLiana
37
36
  @records
38
37
  end
39
38
 
39
+ def belongs_to_and_params_filter
40
+ conditions = filter_param + belongs_to_filter
41
+ @records.where(conditions.join(" #{@params[:filterType]} ".upcase))
42
+ end
43
+
40
44
  def format_column_name(table_name, column_name)
41
45
  ForestLiana::AdapterHelper.format_column_name(table_name, column_name)
42
46
  end
@@ -151,8 +155,9 @@ module ForestLiana
151
155
  end
152
156
 
153
157
  def filter_param
158
+ conditions = []
159
+
154
160
  if @params[:filterType] && @params[:filter]
155
- conditions = []
156
161
 
157
162
  @params[:filter].each do |field, values|
158
163
  # ActsAsTaggable
@@ -174,12 +179,9 @@ module ForestLiana
174
179
  end
175
180
  end
176
181
  end
177
-
178
- operator = " #{@params[:filterType]} ".upcase
179
- @records = @records.where(conditions.join(operator))
180
182
  end
181
183
 
182
- @records
184
+ conditions
183
185
  end
184
186
 
185
187
  def association?(field)
@@ -257,23 +259,20 @@ module ForestLiana
257
259
  [:belongs_to, :has_one].include?(association.try(:macro))
258
260
  end
259
261
 
260
- def belongs_to_subfield_filter(field, value)
261
- condition = OperatorValueParser.get_has_one_condition(@resource, field, value, @params[:timezone])
262
- @records.where(condition) if condition
263
- end
264
-
265
262
  def belongs_to_filter
263
+ conditions = []
264
+
266
265
  if @params[:filter]
267
266
  @params[:filter].each do |field, values|
268
267
  next unless belongs_to_association?(field)
269
268
 
270
269
  values.split(',').each do |value|
271
- @records = belongs_to_subfield_filter(field, value)
270
+ conditions << OperatorValueParser.get_has_one_condition(@resource, field, value, @params[:timezone])
272
271
  end
273
272
  end
274
273
  end
275
274
 
276
- @records
275
+ conditions
277
276
  end
278
277
 
279
278
  private
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "3.0.7"
2
+ VERSION = "3.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails