Add structured errors to schema

This commit is contained in:
Maximilian Grundke
2017-07-03 10:09:48 +02:00
parent 6c353d611d
commit d2a089d057
17 changed files with 144 additions and 1 deletions

View File

@ -0,0 +1,3 @@
class ErrorTemplate < ActiveRecord::Base
belongs_to :execution_environment
end

View File

@ -0,0 +1,3 @@
class ErrorTemplateAttribute < ActiveRecord::Base
belongs_to :error_template
end

View File

@ -0,0 +1,4 @@
class StructuredError < ActiveRecord::Base
belongs_to :error_template
belongs_to :file, class_name: 'CodeOcean::File'
end

View File

@ -0,0 +1,4 @@
class StructuredErrorAttribute < ActiveRecord::Base
belongs_to :structured_error
belongs_to :error_template_attribute
end

View File

@ -0,0 +1,11 @@
class CreateErrorTemplates < ActiveRecord::Migration
def change
create_table :error_templates do |t|
t.belongs_to :execution_environment
t.string :name
t.string :signature
t.timestamps null: false
end
end
end

View File

@ -0,0 +1,11 @@
class CreateErrorTemplateAttributes < ActiveRecord::Migration
def change
create_table :error_template_attributes do |t|
t.belongs_to :error_template
t.string :key
t.string :regex
t.timestamps null: false
end
end
end

View File

@ -0,0 +1,10 @@
class CreateStructuredErrors < ActiveRecord::Migration
def change
create_table :structured_errors do |t|
t.references :error_template
t.belongs_to :file
t.timestamps null: false
end
end
end

View File

@ -0,0 +1,11 @@
class CreateStructuredErrorAttributes < ActiveRecord::Migration
def change
create_table :structured_error_attributes do |t|
t.belongs_to :structured_error
t.references :error_template_attribute
t.string :value
t.timestamps null: false
end
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170608141612) do ActiveRecord::Schema.define(version: 20170703080355) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -47,6 +47,22 @@ ActiveRecord::Schema.define(version: 20170608141612) do
t.string "oauth_secret", limit: 255 t.string "oauth_secret", limit: 255
end end
create_table "error_template_attributes", force: :cascade do |t|
t.integer "error_template_id"
t.string "key"
t.string "regex"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "error_templates", force: :cascade do |t|
t.integer "execution_environment_id"
t.string "name"
t.string "signature"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "errors", force: :cascade do |t| create_table "errors", force: :cascade do |t|
t.integer "execution_environment_id" t.integer "execution_environment_id"
t.text "message" t.text "message"
@ -268,6 +284,21 @@ ActiveRecord::Schema.define(version: 20170608141612) do
t.datetime "updated_at" t.datetime "updated_at"
end end
create_table "structured_error_attributes", force: :cascade do |t|
t.integer "structured_error_id"
t.integer "error_template_attribute_id"
t.string "value"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "structured_errors", force: :cascade do |t|
t.integer "error_template_id"
t.integer "file_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "submissions", force: :cascade do |t| create_table "submissions", force: :cascade do |t|
t.integer "exercise_id" t.integer "exercise_id"
t.float "score" t.float "score"

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :error_template_attribute do
error_template nil
key "MyString"
regex "MyString"
end
end

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :error_template do
execution_environment nil
name "MyString"
signature "MyString"
end
end

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :structured_error_attribute do
structured_error nil
error_template_attribute nil
value "MyString"
end
end

View File

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :structured_error do
error_template nil
file nil
end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ErrorTemplateAttributeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ErrorTemplateTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class StructuredErrorAttributeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class StructuredErrorTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end