searchcraft 0.5.0 → 0.5.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
2
  SHA256:
3
- metadata.gz: baee24eaa1a2af160c50f79554ac35f3944380a161d0d37d78c3aa3c06a2f9c9
4
- data.tar.gz: 5fc8e38ccb127a419fe5b75b8bc2332dba4d1b5ae1c951d0148ad85b72b180cb
3
+ metadata.gz: dcdc1a8d1072f3a64089e24aa0c6682876a00e0f0e0300a3b1552f299a5d4208
4
+ data.tar.gz: a3ced335b1a4042c43936d39af7efc678b3b0f4bfb6e8959260c1ed11da3be66
5
5
  SHA512:
6
- metadata.gz: 8c54aa0216ed4de138df713cdf8ecd9d717591823ac9125f5b1fed43742bfbeae7e6b640ef97fca9854cfc1a45dee79fef4ffca270399e4cc235950e26a71096
7
- data.tar.gz: 19a9f0f01a8676de06524e0f4c87e10fe509bf52c7766dec07f027645fbb85611d1315006664aee5a9d85d27b8fe348d7f04cb79f30b54dfce156182b49789d8
6
+ metadata.gz: 387710b8e2980b3f84539feef53ceec31dac0180f28a3bf12f77cbd3e9932d5d1bd971b4994e0f70719684922e011c2d7cce67b38f59667e02a14a778edb3713
7
+ data.tar.gz: 484faca6fe838694569d563a3df6f5849cf555db4e17191ca3e3d0647dbd9fa09a05cb6fff0231f9dd40a2128c23b52a96ea0c2aef0bddf08e003d55da110d3f
@@ -37,7 +37,7 @@ class SearchCraft::Builder
37
37
  end
38
38
 
39
39
  # Iterate through subclasses, and invoke recreate_view_if_changed!
40
- def rebuild_any_if_changed!
40
+ def rebuild_any_if_changed!(skip_dump_schema: false)
41
41
  SearchCraft::ViewHashStore.setup_table_if_needed!
42
42
 
43
43
  sorted_builders = sort_builders_by_dependency
@@ -51,7 +51,10 @@ class SearchCraft::Builder
51
51
 
52
52
  builders_changed = []
53
53
  sorted_builders.each do |builder|
54
- changed = builder.new.recreate_view_if_changed!(builders_changed: builders_changed)
54
+ changed = builder.new.recreate_view_if_changed!(
55
+ builders_changed: builders_changed,
56
+ skip_dump_schema: skip_dump_schema
57
+ )
55
58
  builders_changed << builder if changed
56
59
  end
57
60
 
@@ -128,7 +131,7 @@ class SearchCraft::Builder
128
131
 
129
132
  # If missing or changed, drop and create view
130
133
  # Returns false if no change required
131
- def recreate_view_if_changed!(builders_changed: [])
134
+ def recreate_view_if_changed!(builders_changed: [], skip_dump_schema: false)
132
135
  if SearchCraft.debug?
133
136
  warn "#{self.class.name}#recreate_view_if_changed!"
134
137
  warn " builders_changed: #{builders_changed.map(&:name).join(", ")}" if builders_changed.any?
@@ -153,7 +156,7 @@ class SearchCraft::Builder
153
156
  drop_view!
154
157
  create_view!
155
158
  update_hash_store!
156
- dump_schema!
159
+ dump_schema! unless skip_dump_schema
157
160
 
158
161
  true
159
162
  end
@@ -176,6 +179,7 @@ class SearchCraft::Builder
176
179
  SearchCraft::ViewHashStore.reset!(builder: self)
177
180
  end
178
181
 
182
+ # TODO: what if indexes didn't change?
179
183
  def recreate_indexes!
180
184
  drop_indexes!
181
185
  create_indexes!
@@ -22,7 +22,6 @@ module SearchCraft::Model
22
22
  # Runs .refresh! on all classes that include SearchCraft::Model
23
23
  def self.refresh_all!
24
24
  included_classes.each do |klass|
25
- warn "Refreshing materialized view #{klass.table_name}..." unless Rails.env.test?
26
25
  if klass.is_a?(ClassMethods)
27
26
  klass.refresh!
28
27
  end
@@ -46,9 +45,19 @@ module SearchCraft::Model
46
45
  module ClassMethods
47
46
  def refresh!
48
47
  refresh_concurrently = @refresh_concurrently && populated?
49
- puts "Refreshing materialized view #{table_name}..." if SearchCraft.debug?
48
+ unless Rails.env.test?
49
+ if refresh_concurrently
50
+ warn "Refreshing materialized view concurrently #{table_name}..."
51
+ else
52
+ warn "Refreshing materialized view #{table_name}..."
53
+ end
54
+ end
50
55
 
51
56
  Scenic.database.refresh_materialized_view(table_name, concurrently: refresh_concurrently, cascade: false)
57
+ rescue ActiveRecord::StatementInvalid
58
+ # If populated? lies and returns true; then might get error:
59
+ # PG::FeatureNotSupported: ERROR: CONCURRENTLY cannot be used when the materialized view is not populated (ActiveRecord::StatementInvalid)
60
+ Scenic.database.refresh_materialized_view(table_name, concurrently: false, cascade: false)
52
61
  end
53
62
 
54
63
  def populated?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SearchCraft
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchcraft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-29 00:00:00.000000000 Z
11
+ date: 2024-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord