effective_resources 2.7.19 → 2.8.0
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 +14 -15
- 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: 750ef0ae89d5b6437e046369b0dc46811abfa26ace4559e9448b190c1e255430
|
4
|
+
data.tar.gz: 7ad14d23604419ba975ab11addf2912f7fbcefe40fdaa9764c7782a2c992cc3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b79973ce6e33a95e792921ecf6cc548fa144b9fb2aa5b550e531f1d7aa613d00e39aa301b71ab802c0e1506c7f31dba6344925e188f2efd3f78a0e071e24efa
|
7
|
+
data.tar.gz: 4bd4b421e3e74108cd95a84cb3283f0740aab2f890532901f5cf0e52b4d4680383c75351612e6d9b59b5cd6f546e844e5d8120ea13c34cc1960cabd503670d6b
|
@@ -62,6 +62,9 @@ module Effective
|
|
62
62
|
when :string, :text
|
63
63
|
relation
|
64
64
|
.order(Arel.sql(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column}='' ASC, #{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s))
|
65
|
+
when :date, :datetime
|
66
|
+
relation
|
67
|
+
.order(Arel.sql(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s))
|
65
68
|
else
|
66
69
|
relation
|
67
70
|
.order(Arel.sql("#{sql_column} #{sql_direction}"))
|
@@ -410,29 +413,25 @@ module Effective
|
|
410
413
|
join = ' AND '
|
411
414
|
else
|
412
415
|
terms = value.split(' ')
|
413
|
-
join = '
|
416
|
+
join = ' AND '
|
414
417
|
end
|
415
418
|
|
416
419
|
terms = (terms - [nil, '', ' ']).map(&:strip)
|
417
420
|
columns = Array(columns)
|
418
421
|
fuzzy = true if fuzzy.nil?
|
419
422
|
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
terms.each do |term|
|
424
|
-
conditions = (
|
425
|
-
if fuzzy
|
426
|
-
columns.map { |name| "#{sql_column(name)} #{ilike} :fuzzy" }
|
427
|
-
else
|
428
|
-
columns.map { |name| "#{sql_column(name)} = :term" }
|
429
|
-
end
|
430
|
-
).join(join)
|
431
|
-
|
432
|
-
searched = collection.where(conditions, fuzzy: "%#{term}%", term: term)
|
423
|
+
terms = terms.inject({}) do |hash, term|
|
424
|
+
hash["term_#{hash.length}".to_sym] = (fuzzy ? "%#{term}%" : term); hash
|
433
425
|
end
|
434
426
|
|
435
|
-
|
427
|
+
# Do any of these columns contain all the terms?
|
428
|
+
conditions = columns.map do |name|
|
429
|
+
keys = terms.keys.map { |key| (fuzzy ? "#{sql_column(name)} #{ilike} :#{key}" : "#{sql_column(name)} = :#{key}") }
|
430
|
+
'(' + keys.join(' AND ') + ')'
|
431
|
+
end.join(' OR ')
|
432
|
+
|
433
|
+
# Do the search
|
434
|
+
collection.where(conditions, terms)
|
436
435
|
end
|
437
436
|
|
438
437
|
def order_by_associated_conditions(association, sort: nil, direction: :asc, limit: nil)
|
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.
|
4
|
+
version: 2.8.0
|
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-06-
|
11
|
+
date: 2023-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|