umbrellio-utils 1.2.1 → 1.4.0

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: aaa7935344d41de32a9d61527b1c7b167d64715207422fc23f83d790950e5951
4
- data.tar.gz: f9d7707ff893d916462b7e584a08ad8171036825eecacc201eecc09b17fc041f
3
+ metadata.gz: 4ed0221575b9cfc5c5350ea8eed168a30e9804b943c20fc357c8ee36c963d767
4
+ data.tar.gz: 18eb1859efe000d5c5d2bb13b57217a84651f0f824542f49c8093439b49d8141
5
5
  SHA512:
6
- metadata.gz: 319224d118b8c1197b9d93855aa83dcb8dbe80b33fb9395d8782e24cbdd4e303ce7bea798f33b4940febfa268d4f457dae0aac55d14e43e5933fd60d9d038362
7
- data.tar.gz: fb536f209a2190fc064db5b0f3a73b01b9286deceab3b7ee83e7f88cbb0023203737b29444baf218b42402dd5e0ad2f2a0bc60edf92bbf0cfbceb1352c5c0f84
6
+ metadata.gz: 2e4077e807ee85ebc7e4db39f3f3e94ee5b75e94fde085082aadcd3d5422a0827522f00d37022cbb1bf6df71a051d5a1faaad53468870fa189f3f496e17d5531
7
+ data.tar.gz: cdd6bce77b7ab07d9ebc975c08551c73f0804540ae9fbff1145965118db40ec0a7f0719b25166ea6e4e5bff2bbc2d01a316b20cfd4a9761074fa9e93bd9d7987
@@ -40,6 +40,7 @@ jobs:
40
40
  - uses: ruby/setup-ruby@v1
41
41
  with:
42
42
  ruby-version: ${{ matrix.ruby }}
43
+ rubygems: latest
43
44
  bundler-cache: true
44
45
 
45
46
  - run: psql -c 'CREATE DATABASE umbrellio_utils_test'
data/Gemfile CHANGED
@@ -5,25 +5,24 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in umbrellio_utils.gemspec
6
6
  gemspec
7
7
 
8
- group :development, :test do
9
- gem "activesupport"
10
- gem "bundler"
11
- gem "ci-helper"
12
- gem "http"
13
- gem "nokogiri", "~> 1.15.0"
14
- gem "nori"
15
- gem "pg"
16
- gem "pry"
17
- gem "rake"
18
- gem "rspec"
19
- gem "rspec-json_matcher"
20
- gem "rubocop-config-umbrellio"
21
- gem "semantic_logger"
22
- gem "sequel"
23
- gem "sequel-batches"
24
- gem "simplecov"
25
- gem "simplecov-lcov"
26
- gem "table_sync"
27
- gem "timecop"
28
- gem "yard"
29
- end
8
+ gem "activesupport"
9
+ gem "bundler"
10
+ gem "ci-helper"
11
+ gem "http"
12
+ gem "net-pop", github: "ruby/net-pop" # See https://stackoverflow.com/questions/78617432/strange-bundle-update-issue-disappearing-net-pop-0-1-2-dependency
13
+ gem "nokogiri"
14
+ gem "nori"
15
+ gem "pg"
16
+ gem "pry"
17
+ gem "rake"
18
+ gem "rspec"
19
+ gem "rspec-json_matcher"
20
+ gem "rubocop-config-umbrellio"
21
+ gem "semantic_logger"
22
+ gem "sequel"
23
+ gem "sequel-batches"
24
+ gem "simplecov"
25
+ gem "simplecov-lcov"
26
+ gem "table_sync"
27
+ gem "timecop"
28
+ gem "yard"
data/Gemfile.lock CHANGED
@@ -1,41 +1,48 @@
1
+ GIT
2
+ remote: https://github.com/ruby/net-pop.git
3
+ revision: e8d0afe2773b9eb6a23c39e9e437f6fc0fc7c733
4
+ specs:
5
+ net-pop (0.1.2)
6
+ net-protocol
7
+
1
8
  PATH
2
9
  remote: .
3
10
  specs:
4
- umbrellio-utils (1.2.1)
11
+ umbrellio-utils (1.4.0)
5
12
  memery (~> 1)
6
13
 
7
14
  GEM
8
15
  remote: https://rubygems.org/
9
16
  specs:
10
- actioncable (7.1.3.2)
11
- actionpack (= 7.1.3.2)
12
- activesupport (= 7.1.3.2)
17
+ actioncable (7.1.3.4)
18
+ actionpack (= 7.1.3.4)
19
+ activesupport (= 7.1.3.4)
13
20
  nio4r (~> 2.0)
14
21
  websocket-driver (>= 0.6.1)
15
22
  zeitwerk (~> 2.6)
16
- actionmailbox (7.1.3.2)
17
- actionpack (= 7.1.3.2)
18
- activejob (= 7.1.3.2)
19
- activerecord (= 7.1.3.2)
20
- activestorage (= 7.1.3.2)
21
- activesupport (= 7.1.3.2)
23
+ actionmailbox (7.1.3.4)
24
+ actionpack (= 7.1.3.4)
25
+ activejob (= 7.1.3.4)
26
+ activerecord (= 7.1.3.4)
27
+ activestorage (= 7.1.3.4)
28
+ activesupport (= 7.1.3.4)
22
29
  mail (>= 2.7.1)
23
30
  net-imap
24
31
  net-pop
25
32
  net-smtp
26
- actionmailer (7.1.3.2)
27
- actionpack (= 7.1.3.2)
28
- actionview (= 7.1.3.2)
29
- activejob (= 7.1.3.2)
30
- activesupport (= 7.1.3.2)
33
+ actionmailer (7.1.3.4)
34
+ actionpack (= 7.1.3.4)
35
+ actionview (= 7.1.3.4)
36
+ activejob (= 7.1.3.4)
37
+ activesupport (= 7.1.3.4)
31
38
  mail (~> 2.5, >= 2.5.4)
32
39
  net-imap
33
40
  net-pop
34
41
  net-smtp
35
42
  rails-dom-testing (~> 2.2)
36
- actionpack (7.1.3.2)
37
- actionview (= 7.1.3.2)
38
- activesupport (= 7.1.3.2)
43
+ actionpack (7.1.3.4)
44
+ actionview (= 7.1.3.4)
45
+ activesupport (= 7.1.3.4)
39
46
  nokogiri (>= 1.8.5)
40
47
  racc
41
48
  rack (>= 2.2.4)
@@ -43,35 +50,35 @@ GEM
43
50
  rack-test (>= 0.6.3)
44
51
  rails-dom-testing (~> 2.2)
45
52
  rails-html-sanitizer (~> 1.6)
46
- actiontext (7.1.3.2)
47
- actionpack (= 7.1.3.2)
48
- activerecord (= 7.1.3.2)
49
- activestorage (= 7.1.3.2)
50
- activesupport (= 7.1.3.2)
53
+ actiontext (7.1.3.4)
54
+ actionpack (= 7.1.3.4)
55
+ activerecord (= 7.1.3.4)
56
+ activestorage (= 7.1.3.4)
57
+ activesupport (= 7.1.3.4)
51
58
  globalid (>= 0.6.0)
52
59
  nokogiri (>= 1.8.5)
53
- actionview (7.1.3.2)
54
- activesupport (= 7.1.3.2)
60
+ actionview (7.1.3.4)
61
+ activesupport (= 7.1.3.4)
55
62
  builder (~> 3.1)
56
63
  erubi (~> 1.11)
57
64
  rails-dom-testing (~> 2.2)
58
65
  rails-html-sanitizer (~> 1.6)
59
- activejob (7.1.3.2)
60
- activesupport (= 7.1.3.2)
66
+ activejob (7.1.3.4)
67
+ activesupport (= 7.1.3.4)
61
68
  globalid (>= 0.3.6)
62
- activemodel (7.1.3.2)
63
- activesupport (= 7.1.3.2)
64
- activerecord (7.1.3.2)
65
- activemodel (= 7.1.3.2)
66
- activesupport (= 7.1.3.2)
69
+ activemodel (7.1.3.4)
70
+ activesupport (= 7.1.3.4)
71
+ activerecord (7.1.3.4)
72
+ activemodel (= 7.1.3.4)
73
+ activesupport (= 7.1.3.4)
67
74
  timeout (>= 0.4.0)
68
- activestorage (7.1.3.2)
69
- actionpack (= 7.1.3.2)
70
- activejob (= 7.1.3.2)
71
- activerecord (= 7.1.3.2)
72
- activesupport (= 7.1.3.2)
75
+ activestorage (7.1.3.4)
76
+ actionpack (= 7.1.3.4)
77
+ activejob (= 7.1.3.4)
78
+ activerecord (= 7.1.3.4)
79
+ activesupport (= 7.1.3.4)
73
80
  marcel (~> 1.0)
74
- activesupport (7.1.3.2)
81
+ activesupport (7.1.3.4)
75
82
  base64
76
83
  bigdecimal
77
84
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -81,15 +88,15 @@ GEM
81
88
  minitest (>= 5.1)
82
89
  mutex_m
83
90
  tzinfo (~> 2.0)
84
- addressable (2.8.6)
85
- public_suffix (>= 2.0.2, < 6.0)
91
+ addressable (2.8.7)
92
+ public_suffix (>= 2.0.2, < 7.0)
86
93
  amazing_print (1.6.0)
87
94
  amq-protocol (2.3.2)
88
95
  ast (2.4.2)
89
96
  base64 (0.2.0)
90
- bigdecimal (3.1.7)
91
- builder (3.2.4)
92
- bunny (2.22.0)
97
+ bigdecimal (3.1.8)
98
+ builder (3.3.0)
99
+ bunny (2.23.0)
93
100
  amq-protocol (~> 2.3, >= 2.3.1)
94
101
  sorted_set (~> 1, >= 1.0.2)
95
102
  ci-helper (0.6.0)
@@ -98,7 +105,7 @@ GEM
98
105
  umbrellio-sequel-plugins (~> 0.14)
99
106
  coderay (1.1.3)
100
107
  colorize (1.1.0)
101
- concurrent-ruby (1.2.3)
108
+ concurrent-ruby (1.3.3)
102
109
  connection_pool (2.4.1)
103
110
  crass (1.0.6)
104
111
  date (3.3.4)
@@ -106,9 +113,12 @@ GEM
106
113
  docile (1.4.0)
107
114
  domain_name (0.6.20240107)
108
115
  drb (2.2.1)
109
- dry-inflector (1.0.0)
110
- erubi (1.12.0)
111
- ffi (1.16.3)
116
+ dry-inflector (1.1.0)
117
+ erubi (1.13.0)
118
+ ffi (1.17.0)
119
+ ffi (1.17.0-arm64-darwin)
120
+ ffi (1.17.0-x86_64-darwin)
121
+ ffi (1.17.0-x86_64-linux-gnu)
112
122
  ffi-compiler (1.3.2)
113
123
  ffi (>= 1.15.5)
114
124
  rake
@@ -120,18 +130,19 @@ GEM
120
130
  http-cookie (~> 1.0)
121
131
  http-form_data (~> 2.2)
122
132
  llhttp-ffi (~> 0.5.0)
123
- http-cookie (1.0.5)
133
+ http-cookie (1.0.6)
124
134
  domain_name (~> 0.5)
125
135
  http-form_data (2.3.0)
126
- i18n (1.14.4)
136
+ i18n (1.14.5)
127
137
  concurrent-ruby (~> 1.0)
128
138
  io-console (0.7.2)
129
- irb (1.12.0)
130
- rdoc
139
+ irb (1.13.2)
140
+ rdoc (>= 4.0.0)
131
141
  reline (>= 0.4.2)
132
142
  json (2.7.2)
133
- lamian (1.8.0)
143
+ lamian (1.9.0)
134
144
  rails (>= 4.2)
145
+ language_server-protocol (3.17.0.3)
135
146
  llhttp-ffi (0.5.0)
136
147
  ffi-compiler (~> 1.0)
137
148
  rake (~> 13.0)
@@ -148,26 +159,30 @@ GEM
148
159
  ruby2_keywords (~> 0.0.2)
149
160
  method_source (1.1.0)
150
161
  mini_mime (1.1.5)
151
- mini_portile2 (2.8.6)
152
- minitest (5.22.3)
162
+ mini_portile2 (2.8.7)
163
+ minitest (5.24.1)
153
164
  mutex_m (0.2.0)
154
- net-imap (0.4.10)
165
+ net-imap (0.4.14)
155
166
  date
156
167
  net-protocol
157
- net-pop (0.1.2)
158
- net-protocol
159
168
  net-protocol (0.2.2)
160
169
  timeout
161
170
  net-smtp (0.5.0)
162
171
  net-protocol
163
- nio4r (2.7.1)
164
- nokogiri (1.15.6)
172
+ nio4r (2.7.3)
173
+ nokogiri (1.16.6)
165
174
  mini_portile2 (~> 2.8.2)
166
175
  racc (~> 1.4)
176
+ nokogiri (1.16.6-arm64-darwin)
177
+ racc (~> 1.4)
178
+ nokogiri (1.16.6-x86_64-darwin)
179
+ racc (~> 1.4)
180
+ nokogiri (1.16.6-x86_64-linux)
181
+ racc (~> 1.4)
167
182
  nori (2.7.0)
168
183
  bigdecimal
169
- parallel (1.24.0)
170
- parser (3.3.0.5)
184
+ parallel (1.25.1)
185
+ parser (3.3.3.0)
171
186
  ast (~> 2.4.1)
172
187
  racc
173
188
  pg (1.5.6)
@@ -176,15 +191,15 @@ GEM
176
191
  method_source (~> 1.0)
177
192
  psych (5.1.2)
178
193
  stringio
179
- public_suffix (5.0.5)
180
- rabbit_messaging (0.13.0)
194
+ public_suffix (6.0.0)
195
+ rabbit_messaging (0.15.0)
181
196
  bunny (~> 2.0)
182
197
  lamian
183
198
  rails (>= 5.2)
184
199
  sneakers (~> 2.0)
185
200
  tainbox
186
- racc (1.7.3)
187
- rack (3.0.10)
201
+ racc (1.8.0)
202
+ rack (3.1.6)
188
203
  rack-session (2.0.0)
189
204
  rack (>= 3.0.0)
190
205
  rack-test (2.1.0)
@@ -192,20 +207,20 @@ GEM
192
207
  rackup (2.1.0)
193
208
  rack (>= 3)
194
209
  webrick (~> 1.8)
195
- rails (7.1.3.2)
196
- actioncable (= 7.1.3.2)
197
- actionmailbox (= 7.1.3.2)
198
- actionmailer (= 7.1.3.2)
199
- actionpack (= 7.1.3.2)
200
- actiontext (= 7.1.3.2)
201
- actionview (= 7.1.3.2)
202
- activejob (= 7.1.3.2)
203
- activemodel (= 7.1.3.2)
204
- activerecord (= 7.1.3.2)
205
- activestorage (= 7.1.3.2)
206
- activesupport (= 7.1.3.2)
210
+ rails (7.1.3.4)
211
+ actioncable (= 7.1.3.4)
212
+ actionmailbox (= 7.1.3.4)
213
+ actionmailer (= 7.1.3.4)
214
+ actionpack (= 7.1.3.4)
215
+ actiontext (= 7.1.3.4)
216
+ actionview (= 7.1.3.4)
217
+ activejob (= 7.1.3.4)
218
+ activemodel (= 7.1.3.4)
219
+ activerecord (= 7.1.3.4)
220
+ activestorage (= 7.1.3.4)
221
+ activesupport (= 7.1.3.4)
207
222
  bundler (>= 1.15.0)
208
- railties (= 7.1.3.2)
223
+ railties (= 7.1.3.4)
209
224
  rails-dom-testing (2.2.0)
210
225
  activesupport (>= 5.0.0)
211
226
  minitest
@@ -213,9 +228,9 @@ GEM
213
228
  rails-html-sanitizer (1.6.0)
214
229
  loofah (~> 2.21)
215
230
  nokogiri (~> 1.14)
216
- railties (7.1.3.2)
217
- actionpack (= 7.1.3.2)
218
- activesupport (= 7.1.3.2)
231
+ railties (7.1.3.4)
232
+ actionpack (= 7.1.3.4)
233
+ activesupport (= 7.1.3.4)
219
234
  irb
220
235
  rackup (>= 1.0.0)
221
236
  rake (>= 12.2)
@@ -224,61 +239,70 @@ GEM
224
239
  rainbow (3.1.1)
225
240
  rake (13.2.1)
226
241
  rbtree (0.4.6)
227
- rdoc (6.6.3.1)
242
+ rdoc (6.7.0)
228
243
  psych (>= 4.0.0)
229
- regexp_parser (2.9.0)
230
- reline (0.5.1)
244
+ regexp_parser (2.9.2)
245
+ reline (0.5.9)
231
246
  io-console (~> 0.5)
232
- rexml (3.2.6)
247
+ rexml (3.3.1)
248
+ strscan
233
249
  rspec (3.13.0)
234
250
  rspec-core (~> 3.13.0)
235
251
  rspec-expectations (~> 3.13.0)
236
252
  rspec-mocks (~> 3.13.0)
237
253
  rspec-core (3.13.0)
238
254
  rspec-support (~> 3.13.0)
239
- rspec-expectations (3.13.0)
255
+ rspec-expectations (3.13.1)
240
256
  diff-lcs (>= 1.2.0, < 2.0)
241
257
  rspec-support (~> 3.13.0)
242
258
  rspec-json_matcher (0.2.0)
243
259
  amazing_print
244
260
  json
245
- rspec-mocks (3.13.0)
261
+ rspec-mocks (3.13.1)
246
262
  diff-lcs (>= 1.2.0, < 2.0)
247
263
  rspec-support (~> 3.13.0)
248
264
  rspec-support (3.13.1)
249
- rubocop (1.50.2)
265
+ rubocop (1.63.5)
250
266
  json (~> 2.3)
267
+ language_server-protocol (>= 3.17.0)
251
268
  parallel (~> 1.10)
252
- parser (>= 3.2.0.0)
269
+ parser (>= 3.3.0.2)
253
270
  rainbow (>= 2.2.2, < 4.0)
254
271
  regexp_parser (>= 1.8, < 3.0)
255
272
  rexml (>= 3.2.5, < 4.0)
256
- rubocop-ast (>= 1.28.0, < 2.0)
273
+ rubocop-ast (>= 1.31.1, < 2.0)
257
274
  ruby-progressbar (~> 1.7)
258
275
  unicode-display_width (>= 2.4.0, < 3.0)
259
- rubocop-ast (1.31.2)
260
- parser (>= 3.3.0.4)
261
- rubocop-capybara (2.20.0)
276
+ rubocop-ast (1.31.3)
277
+ parser (>= 3.3.1.0)
278
+ rubocop-capybara (2.21.0)
262
279
  rubocop (~> 1.41)
263
- rubocop-config-umbrellio (1.50.0.85)
264
- rubocop (~> 1.50.0)
265
- rubocop-performance (~> 1.17.0)
266
- rubocop-rails (~> 2.19.0)
280
+ rubocop-config-umbrellio (1.63.0.93)
281
+ rubocop (~> 1.63.0)
282
+ rubocop-performance (~> 1.21.0)
283
+ rubocop-rails (~> 2.24.0)
267
284
  rubocop-rake (~> 0.6.0)
268
- rubocop-rspec (~> 2.20.0)
285
+ rubocop-rspec (~> 2.29.0)
269
286
  rubocop-sequel (~> 0.3.3)
270
- rubocop-performance (1.17.1)
271
- rubocop (>= 1.7.0, < 2.0)
272
- rubocop-ast (>= 0.4.0)
273
- rubocop-rails (2.19.1)
287
+ rubocop-factory_bot (2.26.1)
288
+ rubocop (~> 1.61)
289
+ rubocop-performance (1.21.1)
290
+ rubocop (>= 1.48.1, < 2.0)
291
+ rubocop-ast (>= 1.31.1, < 2.0)
292
+ rubocop-rails (2.24.1)
274
293
  activesupport (>= 4.2.0)
275
294
  rack (>= 1.1)
276
295
  rubocop (>= 1.33.0, < 2.0)
296
+ rubocop-ast (>= 1.31.1, < 2.0)
277
297
  rubocop-rake (0.6.0)
278
298
  rubocop (~> 1.0)
279
- rubocop-rspec (2.20.0)
280
- rubocop (~> 1.33)
299
+ rubocop-rspec (2.29.2)
300
+ rubocop (~> 1.40)
281
301
  rubocop-capybara (~> 2.17)
302
+ rubocop-factory_bot (~> 2.22)
303
+ rubocop-rspec_rails (~> 2.28)
304
+ rubocop-rspec_rails (2.29.1)
305
+ rubocop (~> 1.61)
282
306
  rubocop-sequel (0.3.4)
283
307
  rubocop (~> 1.0)
284
308
  ruby-progressbar (1.13.0)
@@ -286,7 +310,7 @@ GEM
286
310
  self_data (1.3.0)
287
311
  semantic_logger (4.15.0)
288
312
  concurrent-ruby (~> 1.0)
289
- sequel (5.79.0)
313
+ sequel (5.82.0)
290
314
  bigdecimal
291
315
  sequel-batches (2.0.2)
292
316
  sequel
@@ -310,7 +334,8 @@ GEM
310
334
  sorted_set (1.0.3)
311
335
  rbtree
312
336
  set (~> 1.0)
313
- stringio (3.1.0)
337
+ stringio (3.1.1)
338
+ strscan (3.1.0)
314
339
  symbiont-ruby (0.7.0)
315
340
  table_sync (6.5.0)
316
341
  memery
@@ -320,11 +345,11 @@ GEM
320
345
  tainbox (2.1.2)
321
346
  activesupport
322
347
  thor (1.3.1)
323
- timecop (0.9.8)
348
+ timecop (0.9.10)
324
349
  timeout (0.4.1)
325
350
  tzinfo (2.0.6)
326
351
  concurrent-ruby (~> 1.0)
327
- umbrellio-sequel-plugins (0.14.0.192)
352
+ umbrellio-sequel-plugins (0.15.0.198)
328
353
  sequel
329
354
  symbiont-ruby
330
355
  unicode-display_width (2.5.0)
@@ -333,7 +358,7 @@ GEM
333
358
  websocket-extensions (>= 0.1.0)
334
359
  websocket-extensions (0.1.5)
335
360
  yard (0.9.36)
336
- zeitwerk (2.6.13)
361
+ zeitwerk (2.6.16)
337
362
 
338
363
  PLATFORMS
339
364
  arm64-darwin-20
@@ -348,7 +373,8 @@ DEPENDENCIES
348
373
  bundler
349
374
  ci-helper
350
375
  http
351
- nokogiri (~> 1.15.0)
376
+ net-pop!
377
+ nokogiri
352
378
  nori
353
379
  pg
354
380
  pry
@@ -367,4 +393,4 @@ DEPENDENCIES
367
393
  yard
368
394
 
369
395
  BUNDLED WITH
370
- 2.5.9
396
+ 2.5.14
@@ -22,8 +22,8 @@ module UmbrellioUtils
22
22
  error.result.error_field(PG::Result::PG_DIAG_CONSTRAINT_NAME)
23
23
  end
24
24
 
25
- def each_record(dataset, **options, &block)
26
- primary_key = primary_key_from(dataset, **options)
25
+ def each_record(dataset, primary_key: nil, **options, &block)
26
+ primary_key = primary_key_from(dataset, primary_key: primary_key)
27
27
 
28
28
  with_temp_table(dataset, **options) do |ids|
29
29
  rows = ids.map { |id| row(id.is_a?(Hash) ? id.values : [id]) }
@@ -31,11 +31,28 @@ module UmbrellioUtils
31
31
  end
32
32
  end
33
33
 
34
- def with_temp_table(dataset, page_size: 1_000, sleep: nil, **options)
35
- primary_key = primary_key_from(dataset, **options)
34
+ # Iterates over a dataset and yields batches of primary keys.
35
+ # First, a temporary table is created and populated with dataset primary keys.
36
+ # After that, a batch of rows is deleted from the temp table on each iteration
37
+ # and gets yielded to the caller.
38
+ # @option [Integer] page_size max size of each yielded PK batch
39
+ # @option [Integer] sleep interval to sleep between each iteration
40
+ # @option [Array] primary_key custom primary key to use for dataset
41
+ # @option [Symbol, String] temp_table_name custom name for temporary table,
42
+ # table is reused if already exists
43
+ def with_temp_table(
44
+ dataset,
45
+ page_size: 1_000,
46
+ sleep: nil,
47
+ primary_key: nil,
48
+ temp_table_name: nil
49
+ )
50
+ primary_key = primary_key_from(dataset, primary_key: primary_key)
36
51
  sleep_interval = sleep_interval_from(sleep)
37
52
 
38
- temp_table_name = create_temp_table(dataset, primary_key: primary_key)
53
+ temp_table_name = create_temp_table(
54
+ dataset, primary_key: primary_key, temp_table_name: temp_table_name&.to_sym
55
+ )
39
56
 
40
57
  pk_set = []
41
58
 
@@ -48,30 +65,27 @@ module UmbrellioUtils
48
65
  break if pk_set.empty?
49
66
 
50
67
  Kernel.sleep(sleep_interval) if sleep_interval.positive?
51
- clear_lamian_logs!
52
68
  end
53
- ensure
54
- DB.drop_table(temp_table_name)
55
- end
56
69
 
57
- def clear_lamian_logs!
58
- return unless defined?(Lamian)
59
- Lamian.logger.send(:logdevs).each { |x| x.truncate(0) && x.rewind }
70
+ DB.drop_table(temp_table_name)
60
71
  end
61
72
 
62
- def create_temp_table(dataset, **options)
73
+ def create_temp_table(dataset, primary_key: nil, temp_table_name: nil)
63
74
  time = Time.current
64
75
  model = dataset.model
65
- temp_table_name = "temp_#{model.table_name}_#{time.to_i}_#{time.nsec}".to_sym
66
- primary_key = primary_key_from(dataset, **options)
76
+
77
+ temp_table_name ||= :"temp_#{model.table_name}_#{time.to_i}_#{time.nsec}"
78
+ return temp_table_name if DB.table_exists?(temp_table_name)
79
+
80
+ primary_key = primary_key_from(dataset, primary_key: primary_key)
67
81
 
68
82
  DB.create_table(temp_table_name, unlogged: true) do
69
83
  primary_key.each do |field|
70
84
  type = model.db_schema[field][:db_type]
71
- column field, type
85
+ column(field, type)
72
86
  end
73
87
 
74
- primary_key primary_key
88
+ primary_key(primary_key)
75
89
  end
76
90
 
77
91
  insert_ds = dataset.select(*qualified_pk(model.table_name, primary_key))
@@ -5,7 +5,7 @@ module UmbrellioUtils
5
5
  extend self
6
6
 
7
7
  def secret_engine_present?(engine_path)
8
- ::Vault.logical.read("sys/mounts").data.key?("#{engine_path}/".to_sym)
8
+ ::Vault.logical.read("sys/mounts").data.key?(:"#{engine_path}/")
9
9
  end
10
10
 
11
11
  def create_kv_engine(path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "1.2.1"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Umbrellio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-21 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.5.9
89
+ rubygems_version: 3.5.11
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: A set of utilities that speed up development