marty 2.1.5 → 2.3.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/Gemfile +2 -0
- data/Gemfile.lock +4 -4
- data/app/components/marty/auth_app.rb +3 -3
- data/app/components/marty/auth_app/client/auth_app.js +1 -3
- data/app/components/marty/base_rule_view.rb +32 -20
- data/app/components/marty/data_grid_view.rb +3 -3
- data/app/components/marty/event_view.rb +0 -5
- data/app/components/marty/form.rb +8 -1
- data/app/components/marty/form/client/form.css +3 -0
- data/app/components/marty/grid.rb +174 -33
- data/app/components/marty/import_view.rb +151 -0
- data/app/components/marty/main_auth_app.rb +28 -28
- data/app/components/marty/mcfly_grid_panel.rb +1 -1
- data/app/components/marty/new_posting_form.rb +3 -3
- data/app/components/marty/new_posting_window.rb +5 -6
- data/app/components/marty/posting_grid.rb +2 -2
- data/app/components/marty/posting_window.rb +1 -2
- data/app/components/marty/promise_view.rb +11 -6
- data/app/components/marty/record_form_window.rb +1 -1
- data/app/components/marty/report_form.rb +4 -4
- data/app/components/marty/report_select.rb +1 -1
- data/app/components/marty/script_form.rb +4 -4
- data/app/components/marty/script_grid.rb +2 -2
- data/app/components/marty/script_tester.rb +1 -1
- data/app/components/marty/simple_app.rb +1 -2
- data/app/components/marty/simple_app/client/statusbar_ext.js +1 -1
- data/app/components/marty/tag_grid.rb +1 -1
- data/app/components/marty/user_view.rb +5 -5
- data/app/controllers/marty/job_controller.rb +5 -1
- data/app/models/marty/base.rb +0 -15
- data/app/models/marty/data_grid.rb +1 -1
- data/app/models/marty/log.rb +1 -0
- data/app/models/marty/promise.rb +27 -84
- data/app/models/marty/vw_promise.rb +72 -0
- data/app/views/layouts/marty/application.html.erb +6 -3
- data/config/locales/en.yml +4 -0
- data/db/migrate/410_jsonb_promise_result.rb +9 -0
- data/db/migrate/411_create_vw_promises.rb +26 -0
- data/lib/marty/data_change.rb +3 -4
- data/lib/marty/data_conversion.rb +1 -2
- data/lib/marty/data_importer.rb +13 -14
- data/lib/marty/javascript/{overrides.js → grid_view_in_form.js} +10 -6
- data/lib/marty/mcfly_model.rb +13 -20
- data/lib/marty/monkey.rb +33 -40
- data/lib/marty/promise_job.rb +8 -2
- data/lib/marty/promise_proxy.rb +6 -11
- data/lib/marty/rule_script_set.rb +5 -2
- data/lib/marty/version.rb +1 -1
- data/marty.gemspec +1 -1
- data/other/marty/diagnostic/delayed_job_workers.rb +8 -5
- data/spec/controllers/job_controller_spec.rb +34 -15
- data/spec/dummy/app/components/gemini/my_rule_view.rb +6 -0
- data/spec/dummy/app/models/gemini/helper.rb +2 -2
- data/spec/dummy/config/application.rb +1 -1
- data/spec/features/rule_spec.rb +100 -5
- data/spec/fixtures/csv/rule/MyRule.csv +1 -1
- data/spec/job_helper.rb +2 -4
- data/spec/lib/data_importer_spec.rb +10 -10
- data/spec/lib/delorean_query_spec.rb +13 -2
- data/spec/lib/logger_spec.rb +16 -14
- data/spec/models/data_grid_spec.rb +4 -10
- data/spec/models/promise_spec.rb +8 -8
- data/spec/models/rule_spec.rb +7 -7
- data/spec/spec_helper.rb +1 -1
- metadata +10 -5
@@ -35,14 +35,16 @@ A:
|
|
35
35
|
o = Gemini::FannieBup.
|
36
36
|
order("note_rate DESC", "buy_down ASC").
|
37
37
|
select("note_rate").
|
38
|
-
first.note_rate
|
38
|
+
first.attributes.note_rate
|
39
39
|
|
40
40
|
oo = Gemini::FannieBup.
|
41
41
|
order("note_rate", "buy_down ASC").
|
42
42
|
select("note_rate").
|
43
|
-
find_by("obsoleted_dt = 'infinity'").
|
43
|
+
find_by("obsoleted_dt = 'infinity'").attributes.
|
44
44
|
note_rate
|
45
45
|
|
46
|
+
ooo = Gemini::FannieBup.find_by({'id' : -1})
|
47
|
+
|
46
48
|
g = Gemini::FannieBup.
|
47
49
|
select("settlement_yy*settlement_mm AS x, count(*) AS c").
|
48
50
|
group("settlement_mm", "settlement_yy").
|
@@ -78,6 +80,7 @@ EOF
|
|
78
80
|
@clean_file = "/tmp/clean_#{Process.pid}.psql"
|
79
81
|
save_clean_db(@clean_file)
|
80
82
|
end
|
83
|
+
|
81
84
|
before(:each) do
|
82
85
|
marty_whodunnit
|
83
86
|
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
@@ -90,10 +93,12 @@ EOF
|
|
90
93
|
|
91
94
|
@engine = Marty::ScriptSet.new.get_engine("A")
|
92
95
|
end
|
96
|
+
|
93
97
|
after(:all) do
|
94
98
|
restore_clean_db(@clean_file)
|
95
99
|
Marty::ScriptSet.clear_cache
|
96
100
|
end
|
101
|
+
|
97
102
|
it "perfroms join+count" do
|
98
103
|
res = @engine.evaluate("A", "c", {})
|
99
104
|
|
@@ -147,6 +152,12 @@ EOF
|
|
147
152
|
note_rate
|
148
153
|
end
|
149
154
|
|
155
|
+
it "perfroms find_by on class" do
|
156
|
+
res = @engine.evaluate("A", "ooo", {})
|
157
|
+
|
158
|
+
expect(res).to eq Gemini::FannieBup.find_by(id: -1)
|
159
|
+
end
|
160
|
+
|
150
161
|
it "perfroms group+count" do
|
151
162
|
res = @engine.evaluate("A", "gg", {})
|
152
163
|
|
data/spec/lib/logger_spec.rb
CHANGED
@@ -73,6 +73,7 @@ module Marty
|
|
73
73
|
Marty::Script.load_script_bodies(promise_bodies, Date.today)
|
74
74
|
start_delayed_job
|
75
75
|
end
|
76
|
+
|
76
77
|
after(:all) do
|
77
78
|
restore_clean_db(@clean_file)
|
78
79
|
stop_delayed_job
|
@@ -85,30 +86,31 @@ module Marty
|
|
85
86
|
File.open(Rails.root.join("log/test.log")) do |f|
|
86
87
|
f.seek(0, IO::SEEK_END)
|
87
88
|
engine = Marty::ScriptSet.new.get_engine(NAME_K)
|
88
|
-
|
89
|
+
|
90
|
+
res = (1..1000).map do |i|
|
89
91
|
engine.background_eval("LOGGER", {"msgid" => i}, ["result"])
|
90
92
|
end
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
-
Marty::Promise.unscoped.where(result: nil)
|
95
|
-
}.count
|
96
|
-
break if running == 0
|
97
|
-
sleep 1
|
98
|
-
end
|
94
|
+
# wait for all the jobs to finish; collect/check their result
|
95
|
+
expect(res.map {|x| x["result"]}.sort).to eq (1..1000).to_a
|
99
96
|
|
100
|
-
|
101
|
-
# these must happen no matter what happens in Marty::Logger
|
102
|
-
expect(File.readlines("/tmp/logaction.txt").count).to eq(1000)
|
97
|
+
line_count = File.readlines("/tmp/logaction.txt").count
|
103
98
|
|
104
|
-
# each background_eval does 10 calls to Marty::Logger.
|
105
|
-
# failures (after 3 retries at 0.1 sec each) are logged to rails log
|
106
|
-
# the total count should be 10000
|
107
99
|
log_count = Marty::Log.all.count
|
108
100
|
failed_count = f.readlines.select do
|
109
101
|
|l|
|
110
102
|
l == "Marty::Logger failure: database is locked\n"
|
111
103
|
end.count
|
104
|
+
|
105
|
+
expect(Marty::Promise.where.not(result: {}).count).to eq 1000
|
106
|
+
|
107
|
+
# each background_eval writes one line to /tmp/logaction.txt
|
108
|
+
# these must happen no matter what happens in Marty::Logger
|
109
|
+
expect(line_count).to eq(1000)
|
110
|
+
|
111
|
+
# each background_eval does 10 calls to Marty::Logger.
|
112
|
+
# failures (after 3 retries at 0.1 sec each) are logged to rails log
|
113
|
+
# the total count should be 10000
|
112
114
|
expect(log_count + failed_count).to eq(10000)
|
113
115
|
end
|
114
116
|
end
|
@@ -495,21 +495,15 @@ EOS
|
|
495
495
|
|
496
496
|
expect{lookup_grid_helper('infinity',
|
497
497
|
"G9",
|
498
|
-
{"ltv" => 81},
|
498
|
+
{"state" => nil, "ltv" => 81},
|
499
499
|
)}.to raise_error(/matches > 1/)
|
500
500
|
|
501
|
-
err = /Data Grid lookup failed/
|
502
|
-
expect{lookup_grid_helper('infinity',
|
503
|
-
"G9",
|
504
|
-
{"state" => "CA", "ltv" => nil},
|
505
|
-
false, false)}.to raise_error(err)
|
506
|
-
|
507
501
|
res = lookup_grid_helper('infinity',
|
508
502
|
"G9",
|
509
|
-
{"state" =>
|
503
|
+
{"state" => "CA", "ltv" => nil},
|
510
504
|
false, false)
|
505
|
+
expect(res).to eq [123,"G9"]
|
511
506
|
|
512
|
-
expect(res).to eq [456,"G9"]
|
513
507
|
end
|
514
508
|
|
515
509
|
it "should handle boolean keys" do
|
@@ -776,7 +770,7 @@ EOS
|
|
776
770
|
it "should not create a new version if no change has been made" do
|
777
771
|
dg = dg_from_import("G4", G1)
|
778
772
|
dg.update_from_import("G4", G1)
|
779
|
-
expect(Marty::DataGrid.
|
773
|
+
expect(Marty::DataGrid.where(group_id: dg.group_id).count).to eq 1
|
780
774
|
end
|
781
775
|
|
782
776
|
it "should be able to export and import back grids" do
|
data/spec/models/promise_spec.rb
CHANGED
@@ -19,12 +19,12 @@ describe Marty::Promise, slow: true do
|
|
19
19
|
|
20
20
|
before(:each) do
|
21
21
|
@time = DateTime.now
|
22
|
-
expect(Marty::Promise.
|
22
|
+
expect(Marty::Promise.count).to eq(0)
|
23
23
|
engine = Marty::ScriptSet.new.get_engine(NAME_A)
|
24
24
|
engine.background_eval("Y", {"p_title" => NAME_A}, ["d"])
|
25
25
|
sleep 5
|
26
26
|
Marty::Promise.cleanup
|
27
|
-
expect(Marty::Promise.
|
27
|
+
expect(Marty::Promise.count).to eq(10)
|
28
28
|
end
|
29
29
|
|
30
30
|
after(:each) do
|
@@ -40,24 +40,24 @@ describe Marty::Promise, slow: true do
|
|
40
40
|
it "should retain jobs that were run less than 4 hours ago" do
|
41
41
|
Timecop.freeze(@time + 4.hours)
|
42
42
|
Marty::Promise.cleanup
|
43
|
-
expect(Marty::Promise.
|
43
|
+
expect(Marty::Promise.count).to eq(10)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should cleanup jobs that are older than 4 hours" do
|
47
47
|
Timecop.freeze(@time + 4.hours + 1.minute)
|
48
48
|
Marty::Promise.cleanup
|
49
|
-
expect(Marty::Promise.
|
49
|
+
expect(Marty::Promise.count).to eq(0)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should allow cleanup of all jobs when forced by admin" do
|
53
53
|
Timecop.freeze(@time + 4.hours)
|
54
54
|
Marty::Promise.cleanup(true)
|
55
|
-
expect(Marty::Promise.
|
55
|
+
expect(Marty::Promise.count).to eq(0)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should provide a live search scope for filtering by user or role" do
|
59
|
-
expect(Marty::
|
60
|
-
expect(Marty::
|
61
|
-
expect(Marty::
|
59
|
+
expect(Marty::VwPromise.live_search('XXX').size).to eq(0)
|
60
|
+
expect(Marty::VwPromise.live_search('marty').size).to eq(10)
|
61
|
+
expect(Marty::VwPromise.live_search('Admin').size).to eq(10)
|
62
62
|
end
|
63
63
|
end
|
data/spec/models/rule_spec.rb
CHANGED
@@ -80,28 +80,28 @@ module Marty::RuleSpec
|
|
80
80
|
it "detects errors in computed guards" do
|
81
81
|
@rule_type = "SimpleRule"
|
82
82
|
@computed_guards = {"guard1"=> "zvjsdf12.z8*"}
|
83
|
-
exp = /Computed - Error in rule 'testrule' field 'computed_guards':
|
83
|
+
exp = /Computed - Error in rule 'testrule' field 'computed_guards': Syntax error/
|
84
84
|
expect{subject}.to raise_error(exp)
|
85
85
|
end
|
86
86
|
it "detects errors in computed results" do
|
87
87
|
@rule_type = "SimpleRule"
|
88
88
|
@results = {"does_not_compute"=> "zvjsdf12.z8*"}
|
89
89
|
@grids = {"grid1"=>"DataGrid1","grid2"=>"DataGrid2"}
|
90
|
-
exp = /Computed - Error in rule 'testrule' field 'results':
|
90
|
+
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
91
91
|
expect{subject}.to raise_error(exp)
|
92
92
|
end
|
93
93
|
it "detects errors in computed results 2" do
|
94
94
|
@rule_type = "SimpleRule"
|
95
95
|
@results = {"does_not_compute"=> "zvjsdf12.z8*"}
|
96
96
|
@grids = {"grid1"=>"DataGrid1","grid2"=>"DataGrid1","grid3"=>"DataGrid3"}
|
97
|
-
exp = /Computed - Error in rule 'testrule' field 'results':
|
97
|
+
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
98
98
|
expect{subject}.to raise_error(exp)
|
99
99
|
end
|
100
100
|
it "detects errors in computed results 3" do
|
101
101
|
@rule_type = "SimpleRule"
|
102
102
|
@results = {"does_not_compute"=> "zvjsdf12.z8*"}
|
103
103
|
@grids = {"grid1"=>"DataGrid1","grid2"=>"DataGrid1","grid3"=>"DataGrid1"}
|
104
|
-
exp = /Computed - Error in rule 'testrule' field 'results':
|
104
|
+
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
105
105
|
expect{subject}.to raise_error(exp)
|
106
106
|
end
|
107
107
|
it "reports bad grid names" do
|
@@ -141,19 +141,19 @@ module Marty::RuleSpec
|
|
141
141
|
it "detects script errors" do
|
142
142
|
@rule_type = 'XRule'
|
143
143
|
@results = {"x"=>"zx sdf wer"}
|
144
|
-
exp = /Computed - Error in rule 'testrule' field 'results':
|
144
|
+
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
145
145
|
expect{subject}.to raise_error(exp)
|
146
146
|
end
|
147
147
|
it "rule script stuff overrides 1" do
|
148
148
|
@rule_type = 'XRule'
|
149
149
|
@computed_guards = {"abc"=>"true", "xyz_guard"=> "err err err"}
|
150
|
-
exp = /Computed - Error in rule 'testrule' field 'xyz':
|
150
|
+
exp = /Computed - Error in rule 'testrule' field 'xyz': Syntax error/
|
151
151
|
expect{subject}.to raise_error(exp)
|
152
152
|
end
|
153
153
|
it "rule script stuff overrides 2" do
|
154
154
|
@rule_type = 'XRule'
|
155
155
|
@computed_guards = {"abc"=>"err err err", "xyz_guard"=> "xyz_param"}
|
156
|
-
exp = /Computed - Error in rule 'testrule' field 'computed_guards':
|
156
|
+
exp = /Computed - Error in rule 'testrule' field 'computed_guards': Syntax error/
|
157
157
|
expect{subject}.to raise_error(exp)
|
158
158
|
end
|
159
159
|
it "rule script stuff overrides 3" do
|
data/spec/spec_helper.rb
CHANGED
@@ -47,7 +47,7 @@ class ActiveRecord::Base
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
register_chrome_driver
|
50
|
+
register_chrome_driver(:chrome, chromeOptions: { args: %w[start-maximized]})
|
51
51
|
register_chrome_driver(:headless,
|
52
52
|
chromeOptions: {
|
53
53
|
args: %w[headless disable-gpu window-size=3840,2160]
|
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: 2.
|
4
|
+
version: 2.3.0
|
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: 2018-08-
|
17
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.
|
67
|
+
version: 0.4.00
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.
|
74
|
+
version: 0.4.00
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: mcfly
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,9 +207,11 @@ files:
|
|
207
207
|
- app/components/marty/extras/layout.rb
|
208
208
|
- app/components/marty/extras/misc.rb
|
209
209
|
- app/components/marty/form.rb
|
210
|
+
- app/components/marty/form/client/form.css
|
210
211
|
- app/components/marty/grid.rb
|
211
212
|
- app/components/marty/grid_append_only.rb
|
212
213
|
- app/components/marty/import_type_view.rb
|
214
|
+
- app/components/marty/import_view.rb
|
213
215
|
- app/components/marty/live_search_grid_panel.rb
|
214
216
|
- app/components/marty/log_view.rb
|
215
217
|
- app/components/marty/main_auth_app.rb
|
@@ -435,6 +437,7 @@ files:
|
|
435
437
|
- app/models/marty/token.rb
|
436
438
|
- app/models/marty/user.rb
|
437
439
|
- app/models/marty/user_role.rb
|
440
|
+
- app/models/marty/vw_promise.rb
|
438
441
|
- app/views/layouts/marty/application.html.erb
|
439
442
|
- app/views/marty/diagnostic/diag.html.erb
|
440
443
|
- app/views/marty/diagnostic/op.html.erb
|
@@ -480,6 +483,8 @@ files:
|
|
480
483
|
- db/migrate/303_create_marty_logs.rb
|
481
484
|
- db/migrate/304_drop_marty_api_logs.rb
|
482
485
|
- db/migrate/400_create_dg_plv8_v1_fns.rb
|
486
|
+
- db/migrate/410_jsonb_promise_result.rb
|
487
|
+
- db/migrate/411_create_vw_promises.rb
|
483
488
|
- db/seeds.rb
|
484
489
|
- delorean/diagnostics.dl
|
485
490
|
- delorean/script_report.dl
|
@@ -491,7 +496,7 @@ files:
|
|
491
496
|
- lib/marty/data_exporter.rb
|
492
497
|
- lib/marty/data_importer.rb
|
493
498
|
- lib/marty/engine.rb
|
494
|
-
- lib/marty/javascript/
|
499
|
+
- lib/marty/javascript/grid_view_in_form.js
|
495
500
|
- lib/marty/json_schema.rb
|
496
501
|
- lib/marty/logger.rb
|
497
502
|
- lib/marty/mcfly_model.rb
|