Fix structured error creation if attributes don't match; write match status to database
This commit is contained in:
@ -3,7 +3,15 @@ class StructuredErrorAttribute < ActiveRecord::Base
|
||||
belongs_to :error_template_attribute
|
||||
|
||||
def self.create_from_template(attribute, structured_error, message_buffer)
|
||||
value = message_buffer.match(attribute.regex).captures[0]
|
||||
self.create(structured_error: structured_error, error_template_attribute: attribute, value: value)
|
||||
match = false
|
||||
value = nil
|
||||
result = message_buffer.match(attribute.regex)
|
||||
if result != nil
|
||||
match = true
|
||||
if result.captures.size > 0
|
||||
value = result.captures[0]
|
||||
end
|
||||
end
|
||||
self.create(structured_error: structured_error, error_template_attribute: attribute, value: value, match: match)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddMatchToStructuredErrorAttribute < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :structured_error_attributes, :match, :boolean
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170711170928) do
|
||||
ActiveRecord::Schema.define(version: 20170719133351) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -298,6 +298,7 @@ ActiveRecord::Schema.define(version: 20170711170928) do
|
||||
t.string "value"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "match"
|
||||
end
|
||||
|
||||
create_table "structured_errors", force: :cascade do |t|
|
||||
|
Reference in New Issue
Block a user