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 +4 -4
- data/lib/searchcraft/builder.rb +8 -4
- data/lib/searchcraft/model.rb +11 -2
- data/lib/searchcraft/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: dcdc1a8d1072f3a64089e24aa0c6682876a00e0f0e0300a3b1552f299a5d4208
|
4
|
+
data.tar.gz: a3ced335b1a4042c43936d39af7efc678b3b0f4bfb6e8959260c1ed11da3be66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 387710b8e2980b3f84539feef53ceec31dac0180f28a3bf12f77cbd3e9932d5d1bd971b4994e0f70719684922e011c2d7cce67b38f59667e02a14a778edb3713
|
7
|
+
data.tar.gz: 484faca6fe838694569d563a3df6f5849cf555db4e17191ca3e3d0647dbd9fa09a05cb6fff0231f9dd40a2128c23b52a96ea0c2aef0bddf08e003d55da110d3f
|
data/lib/searchcraft/builder.rb
CHANGED
@@ -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!(
|
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!
|
data/lib/searchcraft/model.rb
CHANGED
@@ -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
|
-
|
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?
|
data/lib/searchcraft/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|