rad_core_rails 0.8.8 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aee20fb677577f2bdbae21a0a002968a70e0f11c052580713f2538e0321252d4
4
- data.tar.gz: fb22e9d2d70617d2b5acc150cda26f662a67b8b58d00dbf264507de870553d3d
3
+ metadata.gz: dae4ae340b06a1da96202cc5dce7e727a3907edc48841586a125db38e427e8c8
4
+ data.tar.gz: 622d9c87e97ff694d590b3dd9002afbe2e83ac0931e86e71a3165be2b7a8348b
5
5
  SHA512:
6
- metadata.gz: 36809f265234f02255bd581587a4e362f985e7eee3f1bf1e2d0dfcde1c1a90b6d4d9e32f20adb1cbbbd35e8e593b376c02b40fe1aacb7435affad55a54f59392
7
- data.tar.gz: '08fea0c02b655b2e8f8ee15453d6bb42afe4e35eaed7461e9d16f06275646a8972e783e92c3290f5652ecd9dac29b7da6d695280280d3bd7237e31100f67554b'
6
+ metadata.gz: 1975e49d1eb90781389bff974d63b0ae0ca948a88ea427258e34dd401b34bf922999f10fb3f0ac5ba5bb96ec5b1bbe03cad4601dc0252b3ea129f16cc39c451b
7
+ data.tar.gz: 8a69180847d8c03ecd95fe3c941d4d04d29bc5416638cf9752cdd7154c84e9e9325f1aa1e0fe46f4d3863028b13133ccdbd470cdc8fdb94fe493b8705e5978f7
@@ -213,7 +213,7 @@ module RadCoreRails
213
213
  [str, args]
214
214
  end
215
215
 
216
- def sanitize_vector_string(search)
216
+ def sanitize_vector_string(search, weight = ':*')
217
217
  phrases_or = search.scan(/\+"([^"]*)"/) # e.g. +"Phrase for OR"
218
218
  # remove 'or' phrases from search if any
219
219
  phrases_or.each { |phrase| search.gsub!('+"' + phrase.first.to_s + '"', '') } if phrases_or.any?
@@ -228,17 +228,17 @@ module RadCoreRails
228
228
 
229
229
  sanitized_and_terms = search.split(' ')
230
230
  .reject { |term| term.include?('+') || term.include?('-') }
231
- .map { |term| term.downcase.strip + ':*' }
231
+ .map { |term| term.downcase.strip + weight }
232
232
  .reject { |t| t.blank? }
233
233
 
234
234
  sanitized_or_terms = search.split(' ')
235
235
  .select { |term| term.include?('+') }
236
- .map { |term| term[1, term.length].downcase + ':*' }
236
+ .map { |term| term[1, term.length].downcase + weight }
237
237
  .reject { |t| t.blank? }
238
238
 
239
239
  sanitized_excluded_terms = search.split(' ')
240
240
  .select { |term| term.include?('-') }
241
- .map { |term| term[1, term.length].downcase.strip + ':*' }
241
+ .map { |term| term[1, term.length].downcase.strip + weight }
242
242
  .reject { |t| t.blank? }
243
243
 
244
244
  and_clause = sanitized_and_terms.join(' & ')
@@ -275,10 +275,11 @@ module RadCoreRails
275
275
  end
276
276
  end
277
277
 
278
- def generate_vector_clause(column_name, filter)
278
+ def generate_vector_clause(column_name, actual_column, filter, weight = ':*')
279
+ return ["(#{actual_column} IS NULL OR #{actual_column} = '')", []] if filter[:option] == '!!'
279
280
  return ['', []] if filter[:values][0].blank?
280
281
 
281
- vector_string = sanitize_vector_string(filter[:values][0])
282
+ vector_string = sanitize_vector_string(filter[:values][0], weight)
282
283
 
283
284
  query = "(#{column_name} @@ to_tsquery('simple', ?))"
284
285
  [query, [vector_string]]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RadCoreRails
4
- VERSION = '0.8.8'
4
+ VERSION = '0.9.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rad_core_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksandr Poltavets, James Marrs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport