bp3-noticed 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +82 -82
- data/lib/bp3/noticed/common_includes.rb +62 -50
- data/lib/bp3/noticed/job_includes.rb +48 -52
- data/lib/bp3/noticed/prepend_perform.rb +66 -61
- data/lib/bp3/noticed/que_includes.rb +53 -49
- data/lib/bp3/noticed/railtie.rb +7 -7
- data/lib/bp3/noticed/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: 17ac709db4d71552e25763221ab6f4ef95211242a1a138458da6a52b1ba84a96
|
|
4
|
+
data.tar.gz: 596bf31f9cf62f4f5c8133e3f5f8aa6808b0ccb95f9f50be16a16dc6d347ca61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b867d294631f28e7a4f39f0f2c842a166d38c7003504680866a077d4520d861f341a6b38a84785cdfdf8b8923afa348a2de42452e0e194f7d98fba1a1f4afdf2
|
|
7
|
+
data.tar.gz: fb876744be692af0fca93141185804a04434a575a1fcd2188bbdce17ed470d8ce725cc2a64651c87db4b3de6209f5daaf60b0e3c04a4453ebcfb2f475b3bfbdd
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bp3-noticed (0.
|
|
4
|
+
bp3-noticed (0.2.0)
|
|
5
5
|
activesupport (>= 7.1.2, < 8)
|
|
6
6
|
bp3-action_dispatch (>= 0.1, < 1)
|
|
7
7
|
bp3-core (>= 0.1, < 1)
|
|
@@ -10,35 +10,35 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
actioncable (7.1.3.
|
|
14
|
-
actionpack (= 7.1.3.
|
|
15
|
-
activesupport (= 7.1.3.
|
|
13
|
+
actioncable (7.1.3.4)
|
|
14
|
+
actionpack (= 7.1.3.4)
|
|
15
|
+
activesupport (= 7.1.3.4)
|
|
16
16
|
nio4r (~> 2.0)
|
|
17
17
|
websocket-driver (>= 0.6.1)
|
|
18
18
|
zeitwerk (~> 2.6)
|
|
19
|
-
actionmailbox (7.1.3.
|
|
20
|
-
actionpack (= 7.1.3.
|
|
21
|
-
activejob (= 7.1.3.
|
|
22
|
-
activerecord (= 7.1.3.
|
|
23
|
-
activestorage (= 7.1.3.
|
|
24
|
-
activesupport (= 7.1.3.
|
|
19
|
+
actionmailbox (7.1.3.4)
|
|
20
|
+
actionpack (= 7.1.3.4)
|
|
21
|
+
activejob (= 7.1.3.4)
|
|
22
|
+
activerecord (= 7.1.3.4)
|
|
23
|
+
activestorage (= 7.1.3.4)
|
|
24
|
+
activesupport (= 7.1.3.4)
|
|
25
25
|
mail (>= 2.7.1)
|
|
26
26
|
net-imap
|
|
27
27
|
net-pop
|
|
28
28
|
net-smtp
|
|
29
|
-
actionmailer (7.1.3.
|
|
30
|
-
actionpack (= 7.1.3.
|
|
31
|
-
actionview (= 7.1.3.
|
|
32
|
-
activejob (= 7.1.3.
|
|
33
|
-
activesupport (= 7.1.3.
|
|
29
|
+
actionmailer (7.1.3.4)
|
|
30
|
+
actionpack (= 7.1.3.4)
|
|
31
|
+
actionview (= 7.1.3.4)
|
|
32
|
+
activejob (= 7.1.3.4)
|
|
33
|
+
activesupport (= 7.1.3.4)
|
|
34
34
|
mail (~> 2.5, >= 2.5.4)
|
|
35
35
|
net-imap
|
|
36
36
|
net-pop
|
|
37
37
|
net-smtp
|
|
38
38
|
rails-dom-testing (~> 2.2)
|
|
39
|
-
actionpack (7.1.3.
|
|
40
|
-
actionview (= 7.1.3.
|
|
41
|
-
activesupport (= 7.1.3.
|
|
39
|
+
actionpack (7.1.3.4)
|
|
40
|
+
actionview (= 7.1.3.4)
|
|
41
|
+
activesupport (= 7.1.3.4)
|
|
42
42
|
nokogiri (>= 1.8.5)
|
|
43
43
|
racc
|
|
44
44
|
rack (>= 2.2.4)
|
|
@@ -46,35 +46,35 @@ GEM
|
|
|
46
46
|
rack-test (>= 0.6.3)
|
|
47
47
|
rails-dom-testing (~> 2.2)
|
|
48
48
|
rails-html-sanitizer (~> 1.6)
|
|
49
|
-
actiontext (7.1.3.
|
|
50
|
-
actionpack (= 7.1.3.
|
|
51
|
-
activerecord (= 7.1.3.
|
|
52
|
-
activestorage (= 7.1.3.
|
|
53
|
-
activesupport (= 7.1.3.
|
|
49
|
+
actiontext (7.1.3.4)
|
|
50
|
+
actionpack (= 7.1.3.4)
|
|
51
|
+
activerecord (= 7.1.3.4)
|
|
52
|
+
activestorage (= 7.1.3.4)
|
|
53
|
+
activesupport (= 7.1.3.4)
|
|
54
54
|
globalid (>= 0.6.0)
|
|
55
55
|
nokogiri (>= 1.8.5)
|
|
56
|
-
actionview (7.1.3.
|
|
57
|
-
activesupport (= 7.1.3.
|
|
56
|
+
actionview (7.1.3.4)
|
|
57
|
+
activesupport (= 7.1.3.4)
|
|
58
58
|
builder (~> 3.1)
|
|
59
59
|
erubi (~> 1.11)
|
|
60
60
|
rails-dom-testing (~> 2.2)
|
|
61
61
|
rails-html-sanitizer (~> 1.6)
|
|
62
|
-
activejob (7.1.3.
|
|
63
|
-
activesupport (= 7.1.3.
|
|
62
|
+
activejob (7.1.3.4)
|
|
63
|
+
activesupport (= 7.1.3.4)
|
|
64
64
|
globalid (>= 0.3.6)
|
|
65
|
-
activemodel (7.1.3.
|
|
66
|
-
activesupport (= 7.1.3.
|
|
67
|
-
activerecord (7.1.3.
|
|
68
|
-
activemodel (= 7.1.3.
|
|
69
|
-
activesupport (= 7.1.3.
|
|
65
|
+
activemodel (7.1.3.4)
|
|
66
|
+
activesupport (= 7.1.3.4)
|
|
67
|
+
activerecord (7.1.3.4)
|
|
68
|
+
activemodel (= 7.1.3.4)
|
|
69
|
+
activesupport (= 7.1.3.4)
|
|
70
70
|
timeout (>= 0.4.0)
|
|
71
|
-
activestorage (7.1.3.
|
|
72
|
-
actionpack (= 7.1.3.
|
|
73
|
-
activejob (= 7.1.3.
|
|
74
|
-
activerecord (= 7.1.3.
|
|
75
|
-
activesupport (= 7.1.3.
|
|
71
|
+
activestorage (7.1.3.4)
|
|
72
|
+
actionpack (= 7.1.3.4)
|
|
73
|
+
activejob (= 7.1.3.4)
|
|
74
|
+
activerecord (= 7.1.3.4)
|
|
75
|
+
activesupport (= 7.1.3.4)
|
|
76
76
|
marcel (~> 1.0)
|
|
77
|
-
activesupport (7.1.3.
|
|
77
|
+
activesupport (7.1.3.4)
|
|
78
78
|
base64
|
|
79
79
|
bigdecimal
|
|
80
80
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
@@ -87,28 +87,28 @@ GEM
|
|
|
87
87
|
ast (2.4.2)
|
|
88
88
|
base64 (0.2.0)
|
|
89
89
|
bigdecimal (3.1.8)
|
|
90
|
-
bp3-action_dispatch (0.1.
|
|
90
|
+
bp3-action_dispatch (0.1.2)
|
|
91
91
|
actionpack (>= 7.1.2, < 8)
|
|
92
92
|
activesupport (>= 7.1.2, < 8)
|
|
93
93
|
i18n (>= 1.8.11, < 2)
|
|
94
|
-
bp3-core (0.1.
|
|
94
|
+
bp3-core (0.1.4)
|
|
95
95
|
actionview (>= 7.1.2, < 8)
|
|
96
96
|
activesupport (>= 7.1.2, < 8)
|
|
97
|
-
builder (3.
|
|
97
|
+
builder (3.3.0)
|
|
98
98
|
byebug (11.1.3)
|
|
99
|
-
concurrent-ruby (1.3.
|
|
99
|
+
concurrent-ruby (1.3.3)
|
|
100
100
|
connection_pool (2.4.1)
|
|
101
101
|
crass (1.0.6)
|
|
102
102
|
date (3.3.4)
|
|
103
103
|
diff-lcs (1.5.1)
|
|
104
104
|
drb (2.2.1)
|
|
105
|
-
erubi (1.
|
|
105
|
+
erubi (1.13.0)
|
|
106
106
|
globalid (1.2.1)
|
|
107
107
|
activesupport (>= 6.1)
|
|
108
108
|
i18n (1.14.5)
|
|
109
109
|
concurrent-ruby (~> 1.0)
|
|
110
110
|
io-console (0.7.2)
|
|
111
|
-
irb (1.
|
|
111
|
+
irb (1.14.0)
|
|
112
112
|
rdoc (>= 4.0.0)
|
|
113
113
|
reline (>= 0.4.2)
|
|
114
114
|
json (2.7.2)
|
|
@@ -123,9 +123,9 @@ GEM
|
|
|
123
123
|
net-smtp
|
|
124
124
|
marcel (1.0.4)
|
|
125
125
|
mini_mime (1.1.5)
|
|
126
|
-
minitest (5.
|
|
126
|
+
minitest (5.24.1)
|
|
127
127
|
mutex_m (0.2.0)
|
|
128
|
-
net-imap (0.4.
|
|
128
|
+
net-imap (0.4.14)
|
|
129
129
|
date
|
|
130
130
|
net-protocol
|
|
131
131
|
net-pop (0.1.2)
|
|
@@ -135,18 +135,18 @@ GEM
|
|
|
135
135
|
net-smtp (0.5.0)
|
|
136
136
|
net-protocol
|
|
137
137
|
nio4r (2.7.3)
|
|
138
|
-
nokogiri (1.16.
|
|
138
|
+
nokogiri (1.16.7-x86_64-darwin)
|
|
139
139
|
racc (~> 1.4)
|
|
140
|
-
noticed (2.
|
|
140
|
+
noticed (2.4.1)
|
|
141
141
|
rails (>= 6.1.0)
|
|
142
|
-
parallel (1.
|
|
143
|
-
parser (3.3.
|
|
142
|
+
parallel (1.25.1)
|
|
143
|
+
parser (3.3.4.0)
|
|
144
144
|
ast (~> 2.4.1)
|
|
145
145
|
racc
|
|
146
146
|
psych (5.1.2)
|
|
147
147
|
stringio
|
|
148
|
-
racc (1.8.
|
|
149
|
-
rack (3.
|
|
148
|
+
racc (1.8.1)
|
|
149
|
+
rack (3.1.7)
|
|
150
150
|
rack-session (2.0.0)
|
|
151
151
|
rack (>= 3.0.0)
|
|
152
152
|
rack-test (2.1.0)
|
|
@@ -154,20 +154,20 @@ GEM
|
|
|
154
154
|
rackup (2.1.0)
|
|
155
155
|
rack (>= 3)
|
|
156
156
|
webrick (~> 1.8)
|
|
157
|
-
rails (7.1.3.
|
|
158
|
-
actioncable (= 7.1.3.
|
|
159
|
-
actionmailbox (= 7.1.3.
|
|
160
|
-
actionmailer (= 7.1.3.
|
|
161
|
-
actionpack (= 7.1.3.
|
|
162
|
-
actiontext (= 7.1.3.
|
|
163
|
-
actionview (= 7.1.3.
|
|
164
|
-
activejob (= 7.1.3.
|
|
165
|
-
activemodel (= 7.1.3.
|
|
166
|
-
activerecord (= 7.1.3.
|
|
167
|
-
activestorage (= 7.1.3.
|
|
168
|
-
activesupport (= 7.1.3.
|
|
157
|
+
rails (7.1.3.4)
|
|
158
|
+
actioncable (= 7.1.3.4)
|
|
159
|
+
actionmailbox (= 7.1.3.4)
|
|
160
|
+
actionmailer (= 7.1.3.4)
|
|
161
|
+
actionpack (= 7.1.3.4)
|
|
162
|
+
actiontext (= 7.1.3.4)
|
|
163
|
+
actionview (= 7.1.3.4)
|
|
164
|
+
activejob (= 7.1.3.4)
|
|
165
|
+
activemodel (= 7.1.3.4)
|
|
166
|
+
activerecord (= 7.1.3.4)
|
|
167
|
+
activestorage (= 7.1.3.4)
|
|
168
|
+
activesupport (= 7.1.3.4)
|
|
169
169
|
bundler (>= 1.15.0)
|
|
170
|
-
railties (= 7.1.3.
|
|
170
|
+
railties (= 7.1.3.4)
|
|
171
171
|
rails-dom-testing (2.2.0)
|
|
172
172
|
activesupport (>= 5.0.0)
|
|
173
173
|
minitest
|
|
@@ -175,9 +175,9 @@ GEM
|
|
|
175
175
|
rails-html-sanitizer (1.6.0)
|
|
176
176
|
loofah (~> 2.21)
|
|
177
177
|
nokogiri (~> 1.14)
|
|
178
|
-
railties (7.1.3.
|
|
179
|
-
actionpack (= 7.1.3.
|
|
180
|
-
activesupport (= 7.1.3.
|
|
178
|
+
railties (7.1.3.4)
|
|
179
|
+
actionpack (= 7.1.3.4)
|
|
180
|
+
activesupport (= 7.1.3.4)
|
|
181
181
|
irb
|
|
182
182
|
rackup (>= 1.0.0)
|
|
183
183
|
rake (>= 12.2)
|
|
@@ -188,51 +188,51 @@ GEM
|
|
|
188
188
|
rdoc (6.7.0)
|
|
189
189
|
psych (>= 4.0.0)
|
|
190
190
|
regexp_parser (2.9.2)
|
|
191
|
-
reline (0.5.
|
|
191
|
+
reline (0.5.9)
|
|
192
192
|
io-console (~> 0.5)
|
|
193
|
-
rexml (3.2
|
|
194
|
-
strscan
|
|
193
|
+
rexml (3.3.2)
|
|
194
|
+
strscan
|
|
195
195
|
rspec (3.13.0)
|
|
196
196
|
rspec-core (~> 3.13.0)
|
|
197
197
|
rspec-expectations (~> 3.13.0)
|
|
198
198
|
rspec-mocks (~> 3.13.0)
|
|
199
199
|
rspec-core (3.13.0)
|
|
200
200
|
rspec-support (~> 3.13.0)
|
|
201
|
-
rspec-expectations (3.13.
|
|
201
|
+
rspec-expectations (3.13.1)
|
|
202
202
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
203
203
|
rspec-support (~> 3.13.0)
|
|
204
204
|
rspec-mocks (3.13.1)
|
|
205
205
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
206
206
|
rspec-support (~> 3.13.0)
|
|
207
207
|
rspec-support (3.13.1)
|
|
208
|
-
rubocop (1.
|
|
208
|
+
rubocop (1.65.0)
|
|
209
209
|
json (~> 2.3)
|
|
210
210
|
language_server-protocol (>= 3.17.0)
|
|
211
211
|
parallel (~> 1.10)
|
|
212
212
|
parser (>= 3.3.0.2)
|
|
213
213
|
rainbow (>= 2.2.2, < 4.0)
|
|
214
|
-
regexp_parser (>=
|
|
214
|
+
regexp_parser (>= 2.4, < 3.0)
|
|
215
215
|
rexml (>= 3.2.5, < 4.0)
|
|
216
216
|
rubocop-ast (>= 1.31.1, < 2.0)
|
|
217
217
|
ruby-progressbar (~> 1.7)
|
|
218
218
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
219
219
|
rubocop-ast (1.31.3)
|
|
220
220
|
parser (>= 3.3.1.0)
|
|
221
|
-
rubocop-capybara (2.
|
|
222
|
-
rubocop (~> 1.41)
|
|
223
|
-
rubocop-factory_bot (2.25.1)
|
|
221
|
+
rubocop-capybara (2.21.0)
|
|
224
222
|
rubocop (~> 1.41)
|
|
223
|
+
rubocop-factory_bot (2.26.1)
|
|
224
|
+
rubocop (~> 1.61)
|
|
225
225
|
rubocop-rake (0.6.0)
|
|
226
226
|
rubocop (~> 1.0)
|
|
227
|
-
rubocop-rspec (2.
|
|
227
|
+
rubocop-rspec (2.31.0)
|
|
228
228
|
rubocop (~> 1.40)
|
|
229
229
|
rubocop-capybara (~> 2.17)
|
|
230
230
|
rubocop-factory_bot (~> 2.22)
|
|
231
231
|
rubocop-rspec_rails (~> 2.28)
|
|
232
|
-
rubocop-rspec_rails (2.
|
|
233
|
-
rubocop (~> 1.
|
|
232
|
+
rubocop-rspec_rails (2.29.1)
|
|
233
|
+
rubocop (~> 1.61)
|
|
234
234
|
ruby-progressbar (1.13.0)
|
|
235
|
-
stringio (3.1.
|
|
235
|
+
stringio (3.1.1)
|
|
236
236
|
strscan (3.1.0)
|
|
237
237
|
thor (1.3.1)
|
|
238
238
|
timeout (0.4.1)
|
|
@@ -243,7 +243,7 @@ GEM
|
|
|
243
243
|
websocket-driver (0.7.6)
|
|
244
244
|
websocket-extensions (>= 0.1.0)
|
|
245
245
|
websocket-extensions (0.1.5)
|
|
246
|
-
zeitwerk (2.6.
|
|
246
|
+
zeitwerk (2.6.17)
|
|
247
247
|
|
|
248
248
|
PLATFORMS
|
|
249
249
|
x86_64-darwin-22
|
|
@@ -1,69 +1,81 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
|
|
3
|
+
module Bp3
|
|
4
|
+
module Noticed
|
|
5
|
+
module CommonIncludes
|
|
6
|
+
extend ActiveSupport::Concern
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
included do
|
|
9
|
+
attr_reader :args, :kwargs
|
|
10
|
+
end
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
class_methods do
|
|
13
|
+
def global_request_state_class
|
|
14
|
+
Bp3::Core::Rqid.global_request_state_class
|
|
15
|
+
end
|
|
16
|
+
end
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
def global_request_state_class
|
|
19
|
+
Bp3::Core::Rqid.global_request_state_class
|
|
20
|
+
end
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
def run(...)
|
|
23
|
+
perform(...)
|
|
24
|
+
end
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
private
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
def set_global_request_state
|
|
29
|
+
global_request_state_class.from_hash(state)
|
|
30
|
+
global_request_state_class.current_site ||= ensure_site
|
|
31
|
+
end
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
def state
|
|
34
|
+
run_attrs :state
|
|
35
|
+
end
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
def ensure_site
|
|
38
|
+
id = run_attrs(:sites_site_id) || run_attrs(:site_id)
|
|
39
|
+
if id.present?
|
|
40
|
+
site = site_class.find_by(id:)
|
|
41
|
+
return site if site.present?
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
message = "Unable to find site #{id}"
|
|
44
|
+
include_log_error(key: 'prepend_state.ensure_site', message:)
|
|
45
|
+
end
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
site_class.root_site || site_class.first
|
|
48
|
+
end
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end
|
|
50
|
+
def include_log_error(key:, message:, details: {})
|
|
51
|
+
return log_error(key:, message:, details:) if respond_to?(:log_error, true)
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
message = "Warning: #{self.class.name}#log_info: unable to log error #{key}/#{message}/#{details}"
|
|
54
|
+
Rails.logger.warn { message }
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
def site_class
|
|
59
|
+
Bp3::ActionDispatch.site_class
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def check(hash_or_array, key)
|
|
63
|
+
return nil if hash_or_array.blank?
|
|
64
|
+
|
|
65
|
+
if hash_or_array.is_a?(Array)
|
|
66
|
+
hash_or_array.each do |obj|
|
|
67
|
+
value = check(obj, key)
|
|
68
|
+
return value if value
|
|
69
|
+
end
|
|
70
|
+
nil
|
|
71
|
+
elsif hash_or_array.is_a?(Hash)
|
|
72
|
+
hash_or_array[key.to_s] || hash_or_array[key.to_sym]
|
|
73
|
+
end
|
|
59
74
|
end
|
|
60
|
-
nil
|
|
61
|
-
elsif hash_or_array.is_a?(Hash)
|
|
62
|
-
hash_or_array[key.to_s] || hash_or_array[key.to_sym]
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
def job_key
|
|
77
|
+
self.class.name.underscore
|
|
78
|
+
end
|
|
79
|
+
end
|
|
68
80
|
end
|
|
69
81
|
end
|
|
@@ -1,70 +1,66 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
|
|
3
|
+
module Bp3
|
|
4
|
+
module Noticed
|
|
5
|
+
module JobIncludes
|
|
6
|
+
extend ActiveSupport::Concern
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
class_methods do
|
|
9
|
+
def enqueue(...)
|
|
10
|
+
new.enqueue(...)
|
|
11
|
+
end
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
def run_now(...)
|
|
14
|
+
perform_later(...) # don't use perform_now, as it won't run in the background
|
|
15
|
+
end
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
def run_soon(...)
|
|
18
|
+
set(wait: 1.minute).perform_later(...)
|
|
19
|
+
end
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
def run_later(...)
|
|
22
|
+
set(wait: 1.hour).perform_later(...)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
def enqueue(*, **)
|
|
27
|
+
# Add state to arguments, not kwargs
|
|
28
|
+
# kwargs['state'] = GlobalRequestState.to_hash
|
|
29
|
+
arguments << { 'state' => global_request_state_class.to_hash }
|
|
30
|
+
super
|
|
31
|
+
end
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
private
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
def job_type
|
|
36
|
+
'job'
|
|
37
|
+
end
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
def run_attrs(key)
|
|
40
|
+
check(arguments, key)
|
|
41
|
+
end
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
nil
|
|
43
|
-
end
|
|
43
|
+
def check(hash_or_array, key)
|
|
44
|
+
return nil if hash_or_array.blank?
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if hash_or_array.is_a?(Array)
|
|
47
|
+
hash_or_array.each do |obj|
|
|
48
|
+
value = check(obj, key)
|
|
49
|
+
return value if value
|
|
50
|
+
end
|
|
51
|
+
nil
|
|
52
|
+
elsif hash_or_array.is_a?(Hash)
|
|
53
|
+
hash_or_array[key.to_s] || hash_or_array[key.to_sym]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
def site
|
|
58
|
+
global_request_state_class.current_site
|
|
59
|
+
end
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
value = check(obj, key)
|
|
55
|
-
return value if value
|
|
61
|
+
def job_key
|
|
62
|
+
self.class.name.underscore
|
|
56
63
|
end
|
|
57
|
-
nil
|
|
58
|
-
elsif hash_or_array.is_a?(Hash)
|
|
59
|
-
hash_or_array[key.to_s] || hash_or_array[key.to_sym]
|
|
60
64
|
end
|
|
61
65
|
end
|
|
62
|
-
|
|
63
|
-
def site
|
|
64
|
-
global_request_state_class.current_site
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def job_key
|
|
68
|
-
self.class.name.underscore
|
|
69
|
-
end
|
|
70
66
|
end
|
|
@@ -1,74 +1,79 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
|
|
3
|
+
module Bp3
|
|
4
|
+
module Noticed
|
|
5
|
+
module PrependPerform
|
|
6
|
+
include CommonIncludes
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
# rubocop:disable Metrics/MethodLength
|
|
9
|
+
def perform(*args, **kwargs)
|
|
10
|
+
@args = args
|
|
11
|
+
@kwargs = kwargs
|
|
12
|
+
set_global_request_state
|
|
13
|
+
details = { args:, kwargs: }
|
|
14
|
+
log = nil
|
|
15
|
+
args = remove_state(args)
|
|
16
|
+
kwargs = remove_state(kwargs)
|
|
17
|
+
begin
|
|
18
|
+
super
|
|
19
|
+
rescue ArgumentError
|
|
20
|
+
super() # in case super is relying on run_attrs
|
|
21
|
+
end
|
|
22
|
+
disposition = 'finished'
|
|
23
|
+
log = prepend_log_info(key: "#{job_type}.#{disposition}.#{job_key}", message: "#{disposition} job_type",
|
|
24
|
+
details:)
|
|
25
|
+
rescue StandardError => e
|
|
26
|
+
disposition = 'failed'
|
|
27
|
+
log = prepend_log_exception(e, key: "#{job_type}.#{disposition}.#{job_key}", details:)
|
|
28
|
+
raise e # to continue the normal job flow
|
|
29
|
+
ensure
|
|
30
|
+
prepend_add_event(eventable: log, disposition:)
|
|
31
|
+
global_request_state_class.clear!
|
|
32
|
+
end
|
|
33
|
+
# rubocop:enable Metrics/MethodLength
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
private
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
def remove_state(obj)
|
|
38
|
+
if obj.is_a?(Hash)
|
|
39
|
+
obj.except(:state, 'state')
|
|
40
|
+
elsif obj.is_a?(Array)
|
|
41
|
+
obj.reject { |e| e.is_a?(Hash) && (e.key?(:state) || e.key?('state')) }
|
|
42
|
+
else
|
|
43
|
+
obj
|
|
44
|
+
end
|
|
45
|
+
end
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
# override in subclasses if needed
|
|
48
|
+
def prepend_add_event(eventable:, disposition:)
|
|
49
|
+
return add_event(eventable:, disposition:) if respond_to?(:add_event, true)
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
creator = global_request_state_class.current_login || global_request_state_class.current_visitor
|
|
52
|
+
who = creator.nil? ? 'nil' : "#{creator.class.name}/#{creator.id}"
|
|
53
|
+
did = disposition
|
|
54
|
+
what = eventable.nil? ? 'nil' : "#{eventable.class.name}/#{eventable.id}"
|
|
55
|
+
message = "Warning: #{self.class.name}#add_event: unable to add event #{who}/#{did}/#{what}"
|
|
56
|
+
Rails.logger.warn { message }
|
|
57
|
+
nil
|
|
58
|
+
end
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
# override in subclasses if needed
|
|
61
|
+
def prepend_log_info(key:, message:, details: {})
|
|
62
|
+
return log_info(key:, message:, details:) if respond_to?(:log_info, true)
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
message = "Warning: #{self.class.name}#log_info: unable to log info #{key}/#{message}/#{details}"
|
|
65
|
+
Rails.logger.warn { message }
|
|
66
|
+
nil
|
|
67
|
+
end
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
# override in subclasses if needed
|
|
70
|
+
def prepend_log_exception(exception, key:, details: {})
|
|
71
|
+
return log_exception(exception, key:, details:) if respond_to?(:log_exception, true)
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
message = "Warning: #{self.class.name}#log_exception: unable to log exception #{exception}/#{key}/#{details}"
|
|
74
|
+
Rails.logger.warn { message }
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
end
|
|
73
78
|
end
|
|
74
79
|
end
|
|
@@ -1,61 +1,65 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def enqueue(*args, **kwargs)
|
|
8
|
-
if ENV.fetch('BP_DEBUG', nil) =~ /quejobs/
|
|
9
|
-
Rails.logger.warn { "enqueue with #{args} and #{kwargs}" }
|
|
10
|
-
Rails.logger.warn { global_request_state_class.to_hash }
|
|
11
|
-
end
|
|
12
|
-
kwargs['state'] = global_request_state_class.to_hash
|
|
13
|
-
super
|
|
14
|
-
end
|
|
3
|
+
module Bp3
|
|
4
|
+
module Noticed
|
|
5
|
+
module QueIncludes
|
|
6
|
+
extend ActiveSupport::Concern
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
class_methods do
|
|
9
|
+
def enqueue(*args, **kwargs)
|
|
10
|
+
if ENV.fetch('BP_DEBUG', nil) =~ /quejobs/
|
|
11
|
+
Rails.logger.warn { "enqueue with #{args} and #{kwargs}" }
|
|
12
|
+
Rails.logger.warn { global_request_state_class.to_hash }
|
|
13
|
+
end
|
|
14
|
+
kwargs['state'] = global_request_state_class.to_hash
|
|
15
|
+
super
|
|
16
|
+
end
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
def perform_now(...)
|
|
19
|
+
run(...)
|
|
20
|
+
end
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
enqueue(*, **kwargs)
|
|
28
|
-
end
|
|
22
|
+
def run_now(...)
|
|
23
|
+
enqueue(...) # don't use perform_now, as it won't run in the background
|
|
24
|
+
end
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
end
|
|
26
|
+
def run_soon(*, **kwargs)
|
|
27
|
+
kwargs[:job_options] ||= {}
|
|
28
|
+
kwargs[:job_options][:run_at] ||= 1.minute.from_now
|
|
29
|
+
enqueue(*, **kwargs)
|
|
30
|
+
end
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else
|
|
44
|
-
false # no need to log
|
|
45
|
-
end
|
|
46
|
-
end
|
|
32
|
+
def run_later(*, **kwargs)
|
|
33
|
+
kwargs[:job_options] ||= {}
|
|
34
|
+
kwargs[:job_options][:run_at] ||= 1.hour.from_now
|
|
35
|
+
enqueue(*, **kwargs)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
47
38
|
|
|
48
|
-
|
|
39
|
+
# set the log level based on the job duration. elapsed is in seconds
|
|
40
|
+
def log_level(elapsed)
|
|
41
|
+
if elapsed > 5
|
|
42
|
+
:warn
|
|
43
|
+
elsif elapsed > 1
|
|
44
|
+
:info
|
|
45
|
+
else
|
|
46
|
+
false # no need to log
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
'que'
|
|
52
|
-
end
|
|
50
|
+
private
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
def job_type
|
|
53
|
+
'que'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def run_attrs(key)
|
|
57
|
+
check(que_attrs, key) ||
|
|
58
|
+
check(que_attrs[:args], key) ||
|
|
59
|
+
check(que_attrs[:kwargs], key) ||
|
|
60
|
+
check(args, key) ||
|
|
61
|
+
check(kwargs, key)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
60
64
|
end
|
|
61
65
|
end
|
data/lib/bp3/noticed/railtie.rb
CHANGED
|
@@ -31,9 +31,9 @@ module Bp3
|
|
|
31
31
|
private
|
|
32
32
|
|
|
33
33
|
def global_scope
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
{
|
|
35
|
+
sites_site_id: global_site_id,
|
|
36
|
+
tenant_id: global_tenant_id,
|
|
37
37
|
workspaces_workspace_id: global_workspace_id
|
|
38
38
|
}
|
|
39
39
|
end
|
|
@@ -67,19 +67,19 @@ module Bp3
|
|
|
67
67
|
|
|
68
68
|
class ApplicationJob
|
|
69
69
|
# include Que::ActiveJob::JobExtensions
|
|
70
|
-
include CommonIncludes
|
|
71
|
-
include JobIncludes
|
|
70
|
+
include Bp3::Noticed::CommonIncludes
|
|
71
|
+
include Bp3::Noticed::JobIncludes
|
|
72
72
|
|
|
73
73
|
# Automatically retry jobs that encountered a deadlock
|
|
74
74
|
retry_on ActiveRecord::Deadlocked
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
class EventJob
|
|
78
|
-
prepend PrependPerform
|
|
78
|
+
prepend Bp3::Noticed::PrependPerform
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
class DeliveryMethod
|
|
82
|
-
prepend PrependPerform
|
|
82
|
+
prepend Bp3::Noticed::PrependPerform
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
data/lib/bp3/noticed/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bp3-noticed
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wim den Braven
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|