effective_resources 2.2.2 → 2.2.3
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 +4 -4
- data/app/models/effective/resources/relation.rb +15 -5
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d4c8949c461fb0b18d3678caf9a4042f365075ee62dcaccc2fdb8959e9a9f88
|
4
|
+
data.tar.gz: 37fac9155c56b4f08329b7c1aa3ace75732837c2a992057bf6a9cb309ea6b16c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f1d0ebbf97e9833f1a5d22a37da11f91eaf86f57a1f3091793373b81d32b352bee94e641816e2efccdbea569ded82db913743e18288ba2eeb40efefe3dc24e5
|
7
|
+
data.tar.gz: d6199a46442c28b8d6c808e80933954d79cb3d7f584a603dd748329b47d58ffa327872e7f102c9a5dbcef4a352d3cec6055e175206b98628dd794e1b34a06328
|
@@ -81,7 +81,7 @@ module Effective
|
|
81
81
|
search_associated(name, value, as: sql_as, operation: sql_operation)
|
82
82
|
else
|
83
83
|
return relation.where(is_null(sql_column)) if value.to_s == 'nil'
|
84
|
-
search_attribute(name, value, as: sql_as, operation: sql_operation)
|
84
|
+
search_attribute(name, value, as: sql_as, operation: sql_operation, sql_column: sql_column)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -274,7 +274,7 @@ module Effective
|
|
274
274
|
retval || raise("unable to search associated #{as} #{operation} #{name} for #{value}")
|
275
275
|
end
|
276
276
|
|
277
|
-
def search_attribute(name, value, as:, operation:)
|
277
|
+
def search_attribute(name, value, as:, operation:, sql_column:)
|
278
278
|
raise 'expected relation to be present' unless relation
|
279
279
|
|
280
280
|
attribute = relation.arel_table[name]
|
@@ -283,6 +283,9 @@ module Effective
|
|
283
283
|
# If you pass an email attribute it can return nil so we return the full value
|
284
284
|
term = Attribute.new(as).parse(value, name: name) || value
|
285
285
|
|
286
|
+
# If using the joined syntax from datatables
|
287
|
+
joined = sql_column.to_s.include?('.')
|
288
|
+
|
286
289
|
searched = case as
|
287
290
|
when :active_storage
|
288
291
|
relation.send("with_attached_#{name}").references("#{name}_attachment")
|
@@ -302,7 +305,12 @@ module Effective
|
|
302
305
|
end
|
303
306
|
)
|
304
307
|
|
305
|
-
|
308
|
+
if joined
|
309
|
+
relation.where("#{sql_column} >= ? AND #{sql_column} <= ?", term, end_at)
|
310
|
+
else
|
311
|
+
relation.where(attribute.gteq(term)).where(attribute.lteq(end_at))
|
312
|
+
end
|
313
|
+
|
306
314
|
end
|
307
315
|
|
308
316
|
when :effective_obfuscation
|
@@ -327,9 +335,11 @@ module Effective
|
|
327
335
|
|
328
336
|
# Simple operation search
|
329
337
|
case operation
|
330
|
-
when :eq then
|
338
|
+
when :eq then
|
339
|
+
joined ? relation.where("#{sql_column} = ?", term) : relation.where(attribute.eq(term))
|
340
|
+
when :matches then
|
341
|
+
joined ? relation.where("#{sql_column} #{ilike} ?", "%#{term}%") : relation.where(attribute.eq(term))
|
331
342
|
when :not_eq then relation.where(attribute.not_eq(term))
|
332
|
-
when :matches then relation.where(attribute.matches("%#{term}%"))
|
333
343
|
when :does_not_match then relation.where(attribute.does_not_match("%#{term}%"))
|
334
344
|
when :starts_with then relation.where(attribute.matches("#{term}%"))
|
335
345
|
when :ends_with then relation.where(attribute.matches("%#{term}"))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|