marty 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/marty/main_auth_app.rb +1 -3
- data/app/models/marty/event.rb +8 -3
- data/db/seeds.rb +3 -2
- data/lib/marty/migrations.rb +1 -2
- data/lib/marty/promise_job.rb +12 -8
- data/lib/marty/version.rb +1 -1
- data/spec/features/scripting_spec.rb +1 -0
- data/spec/models/event_spec.rb +41 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9490119689a36383db480bd8b3f892904a08a3cf
|
4
|
+
data.tar.gz: bc813657c712c00d9b26da1a20c7cb8332a0ffc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bfa1deaffa80e3a1587026420911090696aa1c5221921dbec985b894f1a9ae506234935d6f5dfbae51e4e9079556669c5c393bf76451087072e0867a326cb85
|
7
|
+
data.tar.gz: ad7b61d596677b04ff6445122096103b520912022d79871254a881e8775ee5141728da76d141b3d77b3acfbf344539e027d4f21b54e8b8ec8f005e81246540f1
|
@@ -221,9 +221,7 @@ class Marty::MainAuthApp < Marty::AuthApp
|
|
221
221
|
|
222
222
|
def bg_command(param)
|
223
223
|
e, root, p = ENV['RAILS_ENV'], Rails.root, Marty::Config["RUBY_PATH"]
|
224
|
-
|
225
|
-
# for new Rails apps, use 'bin/delayed_job'
|
226
|
-
dj_path = Marty::Config["DELAYED_JOB_PATH"] || 'script/delayed_job'
|
224
|
+
dj_path = Marty::Config["DELAYED_JOB_PATH"] || 'bin/delayed_job'
|
227
225
|
cmd = "export RAILS_ENV=#{e};"
|
228
226
|
# FIXME: Environment looks to be setup incorrectly - this is a hack
|
229
227
|
cmd += "export PATH=#{p}:$PATH;" if p
|
data/app/models/marty/event.rb
CHANGED
@@ -13,6 +13,10 @@ class Marty::Event < Marty::Base
|
|
13
13
|
|
14
14
|
validates_with EventValidator
|
15
15
|
|
16
|
+
after_validation(on: [:create, :update]) do
|
17
|
+
self.comment = self.comment.truncate(255) if self.comment
|
18
|
+
end
|
19
|
+
|
16
20
|
BASE_QUERY = "SELECT ev.id,
|
17
21
|
ev.klass,
|
18
22
|
ev.subject_id,
|
@@ -102,7 +106,7 @@ class Marty::Event < Marty::Base
|
|
102
106
|
hash = all_running.select do |pm|
|
103
107
|
pm["klass"] == klass && pm["subject_id"] == subject_id.to_i &&
|
104
108
|
(operation.nil? || pm["enum_event_operation"] == operation)
|
105
|
-
end.
|
109
|
+
end.last
|
106
110
|
|
107
111
|
return hash if hash
|
108
112
|
|
@@ -111,7 +115,7 @@ class Marty::Event < Marty::Base
|
|
111
115
|
get_data("SELECT * FROM (#{BASE_QUERY}) sub
|
112
116
|
WHERE klass = '#{klass}'
|
113
117
|
AND subject_id = #{subject_id} #{op_sql}
|
114
|
-
ORDER BY
|
118
|
+
ORDER BY end_dt desc").first
|
115
119
|
end
|
116
120
|
|
117
121
|
def self.currently_running(klass, subject_id)
|
@@ -188,7 +192,8 @@ class Marty::Event < Marty::Base
|
|
188
192
|
ORDER BY end_dt DESC) rownum, *
|
189
193
|
FROM (#{BASE_QUERY}) sub2
|
190
194
|
WHERE end_dt IS NOT NULL and end_dt > '#{cutoff}') sub1
|
191
|
-
WHERE rownum = 1
|
195
|
+
WHERE rownum = 1
|
196
|
+
ORDER BY end_dt"
|
192
197
|
)
|
193
198
|
@all_finished[:timestamp] = time_now_i
|
194
199
|
raw.each_with_object(@all_finished[:data]) do |ev, hash|
|
data/db/seeds.rb
CHANGED
@@ -47,6 +47,7 @@ unless Marty::Tag.find_by_name('DEV')
|
|
47
47
|
tag.save!
|
48
48
|
end
|
49
49
|
|
50
|
-
# one time set up for delayed_job/promises, override
|
50
|
+
# one time set up for delayed_job/promises, override only needed
|
51
|
+
# if DELAYED_JOB_PATH is not bin/delayed_job
|
51
52
|
Marty::Config["DELAYED_JOB_PARAMS"] = "-n 4"
|
52
|
-
Marty::Config["DELAYED_JOB_PATH"] = "
|
53
|
+
# Marty::Config["DELAYED_JOB_PATH"] = "script/delayed_job"
|
data/lib/marty/migrations.rb
CHANGED
@@ -39,9 +39,8 @@ module Marty::Migrations
|
|
39
39
|
SELECT ENUM_RANGE(null::#{enum_name});
|
40
40
|
SQL
|
41
41
|
|
42
|
-
db_values = res.first['enum_range'].gsub(/[{}]/, '').split(',')
|
42
|
+
db_values = res.first['enum_range'].gsub(/[{"}]/, '').split(',')
|
43
43
|
ex_values = klass::VALUES - db_values
|
44
|
-
|
45
44
|
puts "no new #{klass}::VALUES to add" if ex_values.empty?
|
46
45
|
|
47
46
|
#hack to prevent transaction
|
data/lib/marty/promise_job.rb
CHANGED
@@ -13,6 +13,7 @@ class Delorean::BaseModule::NodeCall
|
|
13
13
|
# Monkey-patch '|' method for Delorean NodeCall to create promise
|
14
14
|
# jobs and return promise proxy objects.
|
15
15
|
def |(args)
|
16
|
+
|
16
17
|
if args.is_a?(String)
|
17
18
|
attr = args
|
18
19
|
args = [attr]
|
@@ -56,22 +57,25 @@ class Delorean::BaseModule::NodeCall
|
|
56
57
|
# been reserved yet.
|
57
58
|
promise.job_id = job.id
|
58
59
|
promise.save!
|
60
|
+
|
59
61
|
event = Marty::Event.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
params[
|
62
|
+
create!(promise_id: promise.id,
|
63
|
+
klass: params["p_event"]["klass"],
|
64
|
+
subject_id: params["p_event"]["id"],
|
65
|
+
enum_event_operation:
|
66
|
+
params["p_event"]["operation"]) if
|
67
|
+
params["p_event"]
|
66
68
|
Marty::PromiseProxy.new(promise.id, timeout, attr)
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
72
|
|
71
73
|
class Delorean::Engine
|
72
|
-
def background_eval(node, params, attrs,
|
74
|
+
def background_eval(node, params, attrs, event = {})
|
73
75
|
raise "background_eval bad params" unless params.is_a?(Hash)
|
74
|
-
params[
|
76
|
+
params["p_event"] = event.each_with_object({}) do |(k, v), h|
|
77
|
+
h[k.to_s] = v
|
78
|
+
end unless event.empty?
|
75
79
|
nc = Delorean::BaseModule::NodeCall.new({}, self, node, params)
|
76
80
|
# start the background promise
|
77
81
|
nc | attrs
|
data/lib/marty/version.rb
CHANGED
data/spec/models/event_spec.rb
CHANGED
@@ -4,6 +4,7 @@ require 'job_helper'
|
|
4
4
|
describe Marty::Event do
|
5
5
|
before(:all) do
|
6
6
|
@clean_file = "/tmp/clean_#{Process.pid}.psql"
|
7
|
+
@save_file = "/tmp/save_#{Process.pid}.psql"
|
7
8
|
save_clean_db(@clean_file)
|
8
9
|
|
9
10
|
# transactional fixtures interfere with queueing jobs
|
@@ -48,6 +49,7 @@ describe Marty::Event do
|
|
48
49
|
operation: 'PRICING'})
|
49
50
|
res.force
|
50
51
|
sleep 5
|
52
|
+
save_clean_db(@save_file)
|
51
53
|
end
|
52
54
|
|
53
55
|
after(:all) do
|
@@ -56,8 +58,13 @@ describe Marty::Event do
|
|
56
58
|
stop_delayed_job
|
57
59
|
end
|
58
60
|
|
61
|
+
before(:each) do
|
62
|
+
restore_clean_db(@save_file, false)
|
63
|
+
Marty::Event.clear_cache
|
64
|
+
end
|
65
|
+
|
59
66
|
|
60
|
-
it "
|
67
|
+
it "reports currently running" do
|
61
68
|
expect(Marty::Event.currently_running('testcl1', 123)).to eq(
|
62
69
|
['AVM', 'CRA', 'PRICING'])
|
63
70
|
expect(Marty::Event.currently_running('testcl2', 123)).to eq([])
|
@@ -100,9 +107,12 @@ describe Marty::Event do
|
|
100
107
|
['AVM', 'CRA', 'PRICING'])
|
101
108
|
expect(Marty::Event.currently_running('testcl2', 123)).to eq(
|
102
109
|
[])
|
103
|
-
|
104
110
|
Timecop.return
|
105
111
|
|
112
|
+
end
|
113
|
+
|
114
|
+
it "misc API tests" do
|
115
|
+
|
106
116
|
af = Marty::Event.all_finished
|
107
117
|
expect(af.count).to eq(2)
|
108
118
|
expect(af).to include(['testcl3', 987])
|
@@ -143,6 +153,9 @@ describe Marty::Event do
|
|
143
153
|
expect(af[['testcl1', 123]]).to include('AVM')
|
144
154
|
expect(af[['testcl1', 123]]['AVM']).to start_with(@date_string)
|
145
155
|
|
156
|
+
end
|
157
|
+
|
158
|
+
it "raises on error" do
|
146
159
|
expect {Marty::Event.create_event('testcl', 1234, 'AVM', Time.zone.now, 600,
|
147
160
|
"the comment") }.not_to raise_error
|
148
161
|
|
@@ -164,13 +177,38 @@ describe Marty::Event do
|
|
164
177
|
to raise_error(%r!PG::.*invalid input value for enum.*"AMV"!)
|
165
178
|
Marty::Event.clear_cache
|
166
179
|
af = Marty::Event.all_finished
|
167
|
-
expect(af.count).to eq(
|
180
|
+
expect(af.count).to eq(4)
|
168
181
|
expect(af).to include(['testcl', 1234])
|
169
182
|
expect(af).to include(['testcl', 2345])
|
170
183
|
expect(af[['testcl', 1234]]).to include('AVM')
|
171
184
|
expect(af[['testcl', 2345]]).to include('AVM')
|
172
185
|
expect(af[['testcl', 1234]]['AVM']).to start_with(@date_string)
|
173
186
|
expect(af[['testcl', 2345]]['AVM']).to start_with(@date_string)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "truncates long comment" do
|
190
|
+
long_comment = "comment string abcdefg"*100
|
191
|
+
long_comment_truncated = long_comment.truncate(255)
|
192
|
+
Marty::Event.create_event('testcl', 123, 'PRICING', Time.zone.now, 600,
|
193
|
+
long_comment)
|
194
|
+
Marty::Event.create!(klass: 'testcl',
|
195
|
+
subject_id: 456,
|
196
|
+
enum_event_operation: 'CRA',
|
197
|
+
start_dt: Time.zone.now,
|
198
|
+
expire_secs: 600,
|
199
|
+
comment: long_comment)
|
200
|
+
|
201
|
+
Marty::Event.create_event('testcl', 789, 'AVM', Time.zone.now, 600,
|
202
|
+
"comment")
|
203
|
+
Marty::Event.finish_event('testcl', 789, 'AVM', long_comment)
|
204
|
+
|
205
|
+
e1 = Marty::Event.lookup_event('testcl', 123, 'PRICING').first
|
206
|
+
e2 = Marty::Event.lookup_event('testcl', 456, 'CRA').first
|
207
|
+
e3 = Marty::Event.lookup_event('testcl', 789, 'AVM').first
|
208
|
+
|
209
|
+
expect(e1["comment"]).to eq(long_comment_truncated)
|
210
|
+
expect(e2["comment"]).to eq(long_comment_truncated)
|
211
|
+
expect(e3["comment"]).to eq(long_comment_truncated)
|
174
212
|
|
175
213
|
end
|
176
214
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2016-
|
17
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|