common_indexer 0.3.4 → 0.4.1

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
- SHA1:
3
- metadata.gz: f4c04288510a31222bf983bceb65b31f66e5d95d
4
- data.tar.gz: cb7eafeef3b091eb6db73afdae1f0b90e9037852
2
+ SHA256:
3
+ metadata.gz: 931029ffbaed76ee103cb5bc8dd88dcd88fa1556494d2d3f562c2893fae77c38
4
+ data.tar.gz: 662a785dced385458c692e967d96a71c90aab3fdf9c21a09d6551dc014521f93
5
5
  SHA512:
6
- metadata.gz: 41412f4df6230e21a54dbd3654c06662a14c760188fe65e2f1f7a5d519e150c271273dd075ca6b66022ab0f27387ffe762f0a667afc458776f6bb34d3163804c
7
- data.tar.gz: 7d0c782d6c6a048a4daaf38c6bcbf68382d208275881c83747a2fa73a46d0a90a737522f704d6db472c061e839087952fda04e35a6207a5f81ab78858df9da05
6
+ metadata.gz: e042d390d0c68c4d3abc7d38569434be1740a9ceed64330d30e6a019cea5aeb718ad6cef3ec2e1bcdf6278a2e612dade48684c48329ca124a81d22c5c63913d9
7
+ data.tar.gz: e75f6390d3b751dd0f60e655d1218845454d3b87935c9bfc126f3db25f15b46ff9e32eb3b98417000f455aef3e9ced42fce81cfe292ee6c9063834bb338128cc
@@ -41,8 +41,8 @@ module CommonIndexer # :nodoc:
41
41
 
42
42
  def reindex_into(new_index)
43
43
  existing_index = client.indices.get(index: index_name).keys.first
44
- raise ArgumentError, "Cannot reindex #{index_name} into itself" if existing_index == index_name
45
- client.reindex(body: { source: { index: index_name }, dest: { index: new_index } })
44
+ raise ArgumentError, "Cannot reindex #{index_name} into itself" if existing_index == new_index
45
+ client.reindex(body: { source: { index: existing_index }, dest: { index: new_index } })
46
46
  client.indices.delete(index: existing_index)
47
47
  end
48
48
  end
@@ -4,8 +4,11 @@ require 'active_support/concern'
4
4
  module CommonIndexer # :nodoc:
5
5
  module Base
6
6
  extend ActiveSupport::Concern
7
-
7
+
8
8
  included do
9
+ extend ActiveModel::Callbacks
10
+ define_model_callbacks :delete_common_index, :update_common_index
11
+
9
12
  after_save :update_common_index
10
13
  after_destroy :delete_document
11
14
  end
@@ -16,18 +19,22 @@ module CommonIndexer # :nodoc:
16
19
  end
17
20
 
18
21
  def delete_document
19
- CommonIndexer.client.delete index: CommonIndexer.index_name,
22
+ _run_delete_common_index_callbacks do
23
+ CommonIndexer.client.delete index: CommonIndexer.index_name,
20
24
  id: id,
21
25
  type: '_doc'
26
+ end
22
27
  rescue Elasticsearch::Transport::Transport::Error => err
23
28
  Rails.logger.warn("Common Index delete failure: #{err.message}")
24
29
  end
25
30
 
26
31
  def update_common_index
27
- CommonIndexer.client.index index: CommonIndexer.index_name,
28
- id: id,
29
- type: '_doc',
30
- body: to_common_index
32
+ _run_update_common_index_callbacks do
33
+ CommonIndexer.client.index index: CommonIndexer.index_name,
34
+ id: id,
35
+ type: '_doc',
36
+ body: to_common_index
37
+ end
31
38
  rescue Elasticsearch::Transport::Transport::Error => err
32
39
  Rails.logger.warn("Common Indexing failure: #{err.message}")
33
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommonIndexer
4
- VERSION = '0.3.4'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: common_indexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-03-19 00:00:00.000000000 Z
12
+ date: 2019-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active-fedora
@@ -207,8 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubyforge_project:
211
- rubygems_version: 2.6.8
210
+ rubygems_version: 3.0.1
212
211
  signing_key:
213
212
  specification_version: 4
214
213
  summary: Common Indexing mixin for NUL Digital Collections