speaky 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 6223b310b2223f1af3c8c2c45dc5ebe90aade3ed8cf040b9caad69a03b97e06c
4
- data.tar.gz: 77b50bfbf7925c14f78504774c7502c1018c27ef1e80bd6ebebf743310ed511a
3
+ metadata.gz: b6be1d021d8ebe259d6aa37fe46dc536e8be03b0e4b19309ad06733625bb91ff
4
+ data.tar.gz: 5a5b658cd9ea7878362d436cee77b322be437e0a6bca88db844eb56cd06719af
5
5
  SHA512:
6
- metadata.gz: cd78c665ea63fc51f7ff069e5e7eb1ee41635e9bddcdf1e5f6105762442bb5b7be12ac890742cf9d7e2d62b7aab903a12b11723b45bce6c385fc57c59a23a5eb
7
- data.tar.gz: 491775c48104c32a125934f9e8ffbd5f5960aebc357b08f135e1b78cc640409b1df5923cf0b3e0ac855c1f01ebc161f99b2981d8e6c0b886cf9c4e44e3924783
6
+ metadata.gz: 28e149649e103d758b87dbb73b3417f1fbdf8e0e73838b24f602fc17204fc2a972fee798eed57aa9c0b92d30ffbeae18047eaa845e248af1355dce1f72b006ed
7
+ data.tar.gz: ca90c2c737d2f2e151c2f35a8b2b429f116aeb386c02951aa87e119635d0f06cf86fbd1ab9dc4764014d5c830998d6fd9299dee00d4877282fcaa567f4e961dd
data/README.md CHANGED
@@ -62,8 +62,6 @@ class MyModel < ApplicationRecord
62
62
  end
63
63
 
64
64
  # Add any callbacks that should update the model instance data in the vector store.
65
- after_create :create_for_speaky
66
- after_update :update_for_speaky
67
65
  after_save :save_for_speaky
68
66
  after_destroy :destroy_for_speaky
69
67
  end
@@ -11,7 +11,7 @@ module Speaky
11
11
  self.to_json
12
12
  end
13
13
 
14
- def create_for_speaky
14
+ def save_for_speaky
15
15
  begin
16
16
  Speaky.vectorstore.add(self.id, self.as_speaky)
17
17
  rescue StandardError => e
@@ -21,16 +21,6 @@ module Speaky
21
21
  end
22
22
  end
23
23
 
24
- def update_for_speaky
25
- begin
26
- Speaky.vectorstore.update(self.id, self.as_speaky)
27
- rescue StandardError => e
28
- Rails.logger.error(e)
29
- errors.add(:base, 'Failed to update for speaky')
30
- raise ActiveRecord::Rollback
31
- end
32
- end
33
-
34
24
  def destroy_for_speaky
35
25
  begin
36
26
  Speaky.vectorstore.remove(self.id)
@@ -40,15 +30,5 @@ module Speaky
40
30
  raise ActiveRecord::Rollback
41
31
  end
42
32
  end
43
-
44
- def save_for_speaky
45
- ActiveRecord::Base.transaction do
46
- if self.new_record?
47
- create_for_speaky
48
- else
49
- update_for_speaky
50
- end
51
- end
52
- end
53
33
  end
54
34
  end
@@ -17,13 +17,6 @@ module Speaky
17
17
  raise NotImplementedError
18
18
  end
19
19
 
20
- # Update a vector in the vectorstore.
21
- # NOTE: If the vector does not exist, it will be added.
22
- # Returns a boolean.
23
- def update(id, data)
24
- raise NotImplementedError
25
- end
26
-
27
20
  # Remove a vector from the vectorstore.
28
21
  # NOTE: If the vector does not exist, it will be ignored.
29
22
  # Returns a boolean.
@@ -46,10 +46,6 @@ module Speaky
46
46
  true
47
47
  end
48
48
 
49
- def update(id, data)
50
- add(id, data)
51
- end
52
-
53
49
  def remove(id)
54
50
  points_delete = @client.points.delete(
55
51
  collection_name: @config[:collection_name],
@@ -1,3 +1,3 @@
1
1
  module Speaky
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/lib/speaky.rb CHANGED
@@ -111,11 +111,11 @@ module Speaky
111
111
  Rails.application.eager_load!
112
112
  rails_models = ActiveRecord::Base.descendants
113
113
  rails_models.each do |rails_model|
114
- next unless rails_model.instance_methods.include?(:create_for_speaky)
114
+ next unless rails_model.instance_methods.include?(:save_for_speaky)
115
115
 
116
116
  rails_model.find_in_batches do |batch|
117
117
  batch.each do |record|
118
- record.create_for_speaky
118
+ record.save_for_speaky
119
119
  end
120
120
  end
121
121
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speaky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante