polysearch 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/models/polysearch/searchable.rb +19 -3
- data/lib/polysearch/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: e527bae221d08edf537ee05002258f8cdf982c09f0748eccfee8f170fb83629e
|
4
|
+
data.tar.gz: 3f4d4d07575755d6a89e2d20be671128a861305cc5f41b7437a7d4c88a0a7bb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09093059f97e4f6af87403c21e8eb3b834ba82acfaebfa9708992f7028304d59bfc32cad6a7c38b482d7045a535f6e7c1cbc379416e594ec2fcef65b9a17d445'
|
7
|
+
data.tar.gz: 03f1cf68155d2cf68431e032459363c43252c7bfe359e93a43db3f2cb3ef4827f784ea16ee7539ed34999ad30936a82f735c2eb57857773eb23c6d319ffa581e
|
data/Gemfile.lock
CHANGED
@@ -60,14 +60,30 @@ module Polysearch
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def update_polysearch
|
63
|
+
return unless persisted?
|
63
64
|
tsvectors = to_tsvectors.compact.uniq
|
64
65
|
return if tsvectors.blank?
|
66
|
+
|
65
67
|
tsvectors.pop while tsvectors.size > 500
|
66
68
|
tsvectors.concat similarity_words_tsvectors
|
67
69
|
tsvector = tsvectors.join(" || ")
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
|
71
|
+
attributes = {
|
72
|
+
searchable_type: self.class.name,
|
73
|
+
searchable_id: id,
|
74
|
+
words: similarity_words.join(" "),
|
75
|
+
created_at: Time.current,
|
76
|
+
updated_at: Time.current
|
77
|
+
}
|
78
|
+
|
79
|
+
result = Polysearch::Record.upsert(
|
80
|
+
attributes,
|
81
|
+
unique_by: [:searchable_type, :searchable_id],
|
82
|
+
returning: :id
|
83
|
+
)
|
84
|
+
|
85
|
+
record = Polysearch::Record.find_by(id: result.first["id"])
|
86
|
+
record.update_value tsvector
|
71
87
|
end
|
72
88
|
|
73
89
|
# Polysearch::Searchable#to_tsvectors is abstract... a noop by default
|
data/lib/polysearch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polysearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|