marty 1.2.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -9
- data/Gemfile.lock +93 -80
- data/app/components/marty/data_grid_view.rb +1 -1
- data/app/components/marty/main_auth_app.rb +1 -1
- data/app/components/marty/mcfly_grid_panel/client/dup_in_form.js +1 -1
- data/app/components/marty/posting_grid.rb +1 -1
- data/app/components/marty/promise_view.rb +1 -1
- data/app/components/marty/simple_app.rb +1 -1
- data/app/controllers/marty/application_controller.rb +2 -2
- data/app/controllers/marty/diagnostic/controller.rb +1 -5
- data/app/models/marty/api_auth.rb +6 -4
- data/app/models/marty/config.rb +1 -1
- data/app/models/marty/data_grid.rb +13 -13
- data/app/models/marty/delorean_rule.rb +2 -2
- data/app/models/marty/event.rb +1 -1
- data/app/models/marty/import_type.rb +2 -2
- data/app/models/marty/name_validator.rb +1 -1
- data/app/models/marty/posting.rb +0 -5
- data/app/models/marty/user.rb +1 -1
- data/app/views/marty/diagnostic/diag.html.erb +0 -2
- data/config/routes.rb +2 -2
- data/db/migrate/003_create_marty_users.rb +1 -1
- data/db/migrate/004_create_marty_roles.rb +1 -1
- data/db/migrate/005_create_marty_user_roles.rb +1 -1
- data/db/migrate/006_create_marty_tokens.rb +1 -1
- data/db/migrate/008_create_marty_posting_types.rb +1 -1
- data/db/migrate/068_create_marty_import_types.rb +1 -1
- data/db/migrate/069_create_marty_import_synonyms.rb +1 -1
- data/db/migrate/070_create_versions.rb +1 -1
- data/db/migrate/071_add_object_changes_column_to_versions.rb +1 -1
- data/db/migrate/072_add_validation_function_to_import_types.rb +1 -1
- data/db/migrate/073_add_preprocess_function_to_import_types.rb +1 -1
- data/db/migrate/090_create_delayed_jobs.rb +1 -1
- data/db/migrate/091_create_marty_promises.rb +1 -1
- data/db/migrate/096_add_user_roles_to_import_types.rb +1 -1
- data/db/migrate/097_drop_versions.rb +1 -1
- data/db/migrate/099_create_marty_configs.rb +1 -1
- data/db/migrate/101_create_marty_grid_index_numranges.rb +1 -1
- data/db/migrate/102_create_marty_grid_index_int4ranges.rb +1 -1
- data/db/migrate/103_create_marty_grid_index_integers.rb +1 -1
- data/db/migrate/104_create_marty_grid_index_strings.rb +1 -1
- data/db/migrate/105_create_marty_grid_index_booleans.rb +1 -1
- data/db/migrate/106_make_grid_indexes_nullable.rb +1 -1
- data/db/migrate/200_create_marty_event_operation_enum.rb +1 -1
- data/db/migrate/201_create_marty_events.rb +1 -1
- data/db/migrate/202_add_completion_status_to_event.rb +1 -1
- data/db/migrate/300_create_marty_api_configs.rb +1 -1
- data/db/migrate/301_create_marty_api_log.rb +1 -1
- data/db/migrate/302_add_api_configs_validate_result.rb +1 -1
- data/db/migrate/303_create_marty_logs.rb +1 -1
- data/db/migrate/304_drop_marty_api_logs.rb +1 -1
- data/db/migrate/400_create_dg_plv8_v1_fns.rb +1 -1
- data/lib/marty/migrations.rb +7 -8
- data/lib/marty/monkey.rb +2 -30
- data/lib/marty/version.rb +1 -1
- data/marty.gemspec +3 -4
- data/other/marty/diagnostic/aws/ec2_instance.rb +65 -25
- data/other/marty/diagnostic/base.rb +14 -5
- data/other/marty/diagnostic/collection.rb +1 -0
- data/other/marty/diagnostic/{delayed_job.rb → delayed_job_version.rb} +2 -8
- data/other/marty/diagnostic/delayed_job_workers.rb +11 -0
- data/other/marty/diagnostic/environment_variables.rb +4 -6
- data/other/marty/diagnostic/fatal.rb +0 -5
- data/other/marty/diagnostic/node.rb +4 -3
- data/other/marty/diagnostic/nodes.rb +46 -13
- data/other/marty/diagnostic/packer.rb +22 -25
- data/other/marty/diagnostic/version.rb +19 -21
- data/script_id, +0 -0
- data/spec/controllers/diagnostic/controller_spec.rb +8 -7
- data/spec/controllers/job_controller_spec.rb +5 -5
- data/spec/controllers/rpc_controller_spec.rb +52 -57
- data/spec/controllers/rpc_import_spec.rb +1 -1
- data/spec/dummy/config/environments/test.rb +4 -2
- data/spec/dummy/db/migrate/20140000000000_create_enums.rb +1 -1
- data/spec/dummy/db/migrate/20150406171536_create_categories.rb +2 -2
- data/spec/dummy/db/migrate/20150408200916_create_loan_programs.rb +1 -1
- data/spec/dummy/db/migrate/20150408201429_create_types.rb +1 -1
- data/spec/dummy/db/migrate/20151023000001_create_simple.rb +1 -1
- data/spec/dummy/db/migrate/20160100000038_create_gemini_states.rb +1 -1
- data/spec/dummy/db/migrate/20160923183516_add_bulk_pricing_event_ops.rb +1 -1
- data/spec/dummy/db/migrate/20170706081300_add_state_array_to_lp.rb +1 -1
- data/spec/dummy/db/migrate/20170725160000_add_misc_arrays_to_lp.rb +1 -1
- data/spec/dummy/db/migrate/20171220150101_add_rule_type_enums.rb +1 -1
- data/spec/dummy/db/migrate/20171222150100_add_rule_indices.rb +1 -1
- data/spec/features/auth_app_spec.rb +1 -0
- data/spec/features/data_import_spec.rb +2 -2
- data/spec/features/log_view_spec.rb +4 -4
- data/spec/features/reporting_spec.rb +16 -19
- data/spec/features/rule_spec.rb +11 -8
- data/spec/features/scripting_spec.rb +2 -2
- data/spec/features/scripting_test_spec.rb +0 -2
- data/spec/features/user_view_spec.rb +4 -6
- data/spec/lib/logger_spec.rb +4 -4
- data/spec/models/event_spec.rb +4 -4
- data/spec/models/promise_spec.rb +1 -1
- data/spec/other/diagnostic/base_spec.rb +12 -12
- data/spec/other/diagnostic/collection_spec.rb +8 -8
- data/spec/other/diagnostic/{delayed_job_spec.rb → delayed_job_version_spec.rb} +4 -4
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +44 -0
- data/spec/other/diagnostic/reporter_spec.rb +13 -17
- data/spec/spec_helper.rb +36 -14
- data/spec/support/clean_db_helpers.rb +2 -2
- metadata +14 -39
data/app/models/marty/config.rb
CHANGED
@@ -15,19 +15,19 @@ class Marty::DataGrid < Marty::Base
|
|
15
15
|
class DataGridValidator < ActiveModel::Validator
|
16
16
|
def validate(dg)
|
17
17
|
|
18
|
-
dg.errors
|
18
|
+
dg.errors.add(:base, "'#{dg.data_type}' not a defined type or class") unless
|
19
19
|
Marty::DataGrid.convert_data_type(dg.data_type)
|
20
20
|
|
21
|
-
dg.errors
|
21
|
+
dg.errors.add(:base, "data must be array of arrays") unless
|
22
22
|
dg.data.is_a?(Array) && dg.data.all? {|a| a.is_a? Array}
|
23
23
|
|
24
|
-
dg.errors
|
24
|
+
dg.errors.add(:base, "metadata must be an array of hashes") unless
|
25
25
|
dg.metadata.is_a?(Array) && dg.metadata.all? {|a| a.is_a? Hash}
|
26
26
|
|
27
|
-
dg.errors
|
27
|
+
dg.errors.add(:base, "metadata must contain only h/v dirs") unless
|
28
28
|
dg.metadata.all? {|h| ["h", "v"].member? h["dir"]}
|
29
29
|
|
30
|
-
dg.errors
|
30
|
+
dg.errors.add(:base, "metadata item attrs must be unique") unless
|
31
31
|
dg.metadata.map {|h| h["attr"]}.uniq.length == dg.metadata.length
|
32
32
|
|
33
33
|
dg.metadata.each do
|
@@ -39,22 +39,22 @@ class Marty::DataGrid < Marty::Base
|
|
39
39
|
unless rs_keep.nil? || rs_keep.empty?
|
40
40
|
m = /\A *(<|<=|>|>=)? *([a-z_]+) *\z/.match(rs_keep)
|
41
41
|
unless m
|
42
|
-
dg.errors
|
42
|
+
dg.errors.add(:base, "invalid grid modifier expression: #{rs_keep}")
|
43
43
|
next
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
dg.errors
|
47
|
+
dg.errors.add(:base, "metadata elements must have attr/type/keys") unless
|
48
48
|
attr && type && keys
|
49
49
|
|
50
50
|
# enforce Delorean attr syntax (a bit Draconian)
|
51
|
-
dg.errors
|
51
|
+
dg.errors.add(:base, "bad attribute '#{attr}'") unless
|
52
52
|
attr =~ /^[a-z][A-Za-z0-9_]*$/
|
53
53
|
|
54
|
-
dg.errors
|
54
|
+
dg.errors.add(:base, "unknown metadata type #{type}") unless
|
55
55
|
Marty::DataGrid.type_to_index(type)
|
56
56
|
|
57
|
-
dg.errors
|
57
|
+
dg.errors.add(:base, "bad metadata keys") unless
|
58
58
|
keys.is_a?(Array) && keys.length>0
|
59
59
|
end
|
60
60
|
|
@@ -68,10 +68,10 @@ class Marty::DataGrid < Marty::Base
|
|
68
68
|
v_zip_keys = v_keys.empty? ? [] : v_keys[0].zip(*v_keys[1..-1])
|
69
69
|
h_zip_keys = h_keys.empty? ? [] : h_keys[0].zip(*h_keys[1..-1])
|
70
70
|
|
71
|
-
dg.errors
|
71
|
+
dg.errors.add(:base, "duplicate horiz. key combination") unless
|
72
72
|
h_zip_keys.uniq.length == h_zip_keys.length
|
73
73
|
|
74
|
-
dg.errors
|
74
|
+
dg.errors.add(:base, "duplicate vertical key combination") unless
|
75
75
|
v_zip_keys.uniq.length == v_zip_keys.length
|
76
76
|
end
|
77
77
|
end
|
@@ -589,7 +589,7 @@ class Marty::DataGrid < Marty::Base
|
|
589
589
|
self.data = data
|
590
590
|
self.data_type = data_type
|
591
591
|
self.lenient = !!lenient
|
592
|
-
self.metadata = metadata
|
592
|
+
self.metadata = metadata unless self.metadata == metadata # Otherwise changed will depend on order in hashes
|
593
593
|
self.created_dt = created_dt if created_dt
|
594
594
|
save!
|
595
595
|
end
|
@@ -5,7 +5,7 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
5
5
|
|
6
6
|
def validate
|
7
7
|
super
|
8
|
-
return errors[:base]
|
8
|
+
return errors[:base] << "Start date must be before end date" if
|
9
9
|
start_dt && end_dt && start_dt >= end_dt
|
10
10
|
|
11
11
|
if computed_guards.present? || results.present?
|
@@ -13,7 +13,7 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
13
13
|
eclass = engine && engine.constantize || Marty::RuleScriptSet
|
14
14
|
eng = eclass.new('infinity').get_engine(self_as_hash)
|
15
15
|
rescue => e
|
16
|
-
return errors[:computed]
|
16
|
+
return errors[:computed] << "- " + e.message
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/app/models/marty/event.rb
CHANGED
@@ -2,7 +2,7 @@ class Marty::Event < Marty::Base
|
|
2
2
|
|
3
3
|
class EventValidator < ActiveModel::Validator
|
4
4
|
def validate(event)
|
5
|
-
event.errors[:base]
|
5
|
+
event.errors[:base] << "Must have promise_id or start_dt" unless
|
6
6
|
event.promise_id || event.start_dt
|
7
7
|
end
|
8
8
|
end
|
@@ -4,7 +4,7 @@ class Marty::ImportType < Marty::Base
|
|
4
4
|
klass = entry.get_model_class
|
5
5
|
|
6
6
|
unless klass.is_a?(Class) && klass < ActiveRecord::Base
|
7
|
-
entry.errors
|
7
|
+
entry.errors.add :base, "bad model name"
|
8
8
|
return
|
9
9
|
end
|
10
10
|
|
@@ -13,7 +13,7 @@ class Marty::ImportType < Marty::Base
|
|
13
13
|
entry.validation_function,
|
14
14
|
entry.preprocess_function,
|
15
15
|
].each { |func|
|
16
|
-
entry.errors
|
16
|
+
entry.errors.add(:base, "unknown class method #{func}") if
|
17
17
|
func && !klass.respond_to?(func.to_sym)
|
18
18
|
}
|
19
19
|
end
|
@@ -8,7 +8,7 @@ class Marty::NameValidator < ActiveModel::Validator
|
|
8
8
|
|
9
9
|
# disallow leading, trailing, >1 internal spaces, special chars (|)
|
10
10
|
if value =~ /\A\s|\s\z|\A.*\s\s.*\z|.*\|.*/
|
11
|
-
entry.errors[field]
|
11
|
+
entry.errors[field] <<
|
12
12
|
I18n.t("activerecord.errors.messages.extraneous_spaces")
|
13
13
|
end
|
14
14
|
end
|
data/app/models/marty/posting.rb
CHANGED
data/app/models/marty/user.rb
CHANGED
data/config/routes.rb
CHANGED
@@ -3,8 +3,8 @@ Rails.application.routes.draw do
|
|
3
3
|
end
|
4
4
|
|
5
5
|
Marty::Engine.routes.draw do
|
6
|
-
match via: [:get, :post], "rpc
|
7
|
-
get "job/:action" => "job", as: :job
|
6
|
+
match via: [:get, :post], "rpc/evaluate(.:format)" => "rpc", as: :rpc
|
8
7
|
match via: [:get, :post], "report(.:format)" => "report#index", as: :report
|
8
|
+
get 'job/download' => 'job', as: :job
|
9
9
|
get 'diag', to: 'diagnostic/#op'
|
10
10
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateDelayedJobs < ActiveRecord::Migration
|
1
|
+
class CreateDelayedJobs < ActiveRecord::Migration[4.2]
|
2
2
|
def self.up
|
3
3
|
create_table :delayed_jobs, :force => true do |table|
|
4
4
|
table.integer :priority, :default => 0, :null => false # Allows some jobs to jump to the front of the queue
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddApiConfigsValidateResult < ActiveRecord::Migration
|
1
|
+
class AddApiConfigsValidateResult < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
rename_column :marty_api_configs, :validated, :input_validated
|
4
4
|
add_column :marty_api_configs, :output_validated, :boolean, null: false,
|
data/lib/marty/migrations.rb
CHANGED
@@ -70,7 +70,7 @@ module Marty::Migrations
|
|
70
70
|
fk_opts(from_table,
|
71
71
|
to_table,
|
72
72
|
options[:column]).update(options),
|
73
|
-
|
73
|
+
)
|
74
74
|
end
|
75
75
|
|
76
76
|
# created_dt/obsoleted_dt need to be indexed since they appear in
|
@@ -101,11 +101,10 @@ module Marty::Migrations
|
|
101
101
|
attrs,
|
102
102
|
unique: true,
|
103
103
|
name: unique_index_name(klass)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
) unless index_exists?(klass.table_name.to_sym,
|
105
|
+
attrs,
|
106
|
+
name: unique_index_name(klass),
|
107
|
+
unique: true)
|
109
108
|
end
|
110
109
|
|
111
110
|
def remove_mcfly_unique_index(klass)
|
@@ -231,7 +230,7 @@ EOSQL
|
|
231
230
|
# before EOL. GO in comments could trigger this and will cause an error
|
232
231
|
File.open(mig_name, "w") do |f|
|
233
232
|
f.print <<OUT
|
234
|
-
class #{klass.camelcase} < ActiveRecord::Migration
|
233
|
+
class #{klass.camelcase} < ActiveRecord::Migration[4.2]
|
235
234
|
|
236
235
|
def up
|
237
236
|
path = #{sql_snap_call}
|
@@ -257,7 +256,7 @@ OUT
|
|
257
256
|
ActiveRecord::Base.
|
258
257
|
connection.execute(<<-SQL).to_a.first.try{|v| v['id']}
|
259
258
|
select id from #{klass.table_name} where name =
|
260
|
-
#{ActiveRecord::Base.
|
259
|
+
#{ActiveRecord::Base.connection.quote(name)}
|
261
260
|
SQL
|
262
261
|
end
|
263
262
|
|