Add subscription model and link it to RFC
This commit is contained in:
@ -5,6 +5,8 @@ class RequestForComment < ActiveRecord::Base
|
|||||||
belongs_to :file, class_name: 'CodeOcean::File'
|
belongs_to :file, class_name: 'CodeOcean::File'
|
||||||
|
|
||||||
has_many :comments, through: :submission
|
has_many :comments, through: :submission
|
||||||
|
has_many :subscriptions
|
||||||
|
has_many :subscribers, through: :subscriptions, source: :user, source_type: ExternalUser
|
||||||
|
|
||||||
scope :unsolved, -> { where(solved: [false, nil]) }
|
scope :unsolved, -> { where(solved: [false, nil]) }
|
||||||
|
|
||||||
|
4
app/models/subscription.rb
Normal file
4
app/models/subscription.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class Subscription < ActiveRecord::Base
|
||||||
|
belongs_to :user, polymorphic: true
|
||||||
|
belongs_to :request_for_comment
|
||||||
|
end
|
11
db/migrate/20170906124500_create_subscriptions.rb
Normal file
11
db/migrate/20170906124500_create_subscriptions.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class CreateSubscriptions < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :subscriptions do |t|
|
||||||
|
t.belongs_to :user, polymorphic: true
|
||||||
|
t.references :request_for_comment
|
||||||
|
t.string :type
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
51
db/schema.rb
51
db/schema.rb
@ -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: 20170906124500) 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,30 @@ 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.string "key"
|
||||||
|
t.string "regex"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.text "description"
|
||||||
|
t.boolean "important"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "error_template_attributes_templates", id: false, force: :cascade do |t|
|
||||||
|
t.integer "error_template_id", null: false
|
||||||
|
t.integer "error_template_attribute_id", 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
|
||||||
|
t.text "description"
|
||||||
|
t.text "hint"
|
||||||
|
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 +292,22 @@ 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
|
||||||
|
t.boolean "match"
|
||||||
|
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"
|
||||||
@ -281,6 +321,15 @@ ActiveRecord::Schema.define(version: 20170608141612) do
|
|||||||
add_index "submissions", ["exercise_id"], name: "index_submissions_on_exercise_id", using: :btree
|
add_index "submissions", ["exercise_id"], name: "index_submissions_on_exercise_id", using: :btree
|
||||||
add_index "submissions", ["user_id"], name: "index_submissions_on_user_id", using: :btree
|
add_index "submissions", ["user_id"], name: "index_submissions_on_user_id", using: :btree
|
||||||
|
|
||||||
|
create_table "subscriptions", force: :cascade do |t|
|
||||||
|
t.integer "user_id"
|
||||||
|
t.string "user_type"
|
||||||
|
t.integer "request_for_comment_id"
|
||||||
|
t.string "type"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "tags", force: :cascade do |t|
|
create_table "tags", force: :cascade do |t|
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
7
test/factories/subscriptions.rb
Normal file
7
test/factories/subscriptions.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :subscription do
|
||||||
|
user nil
|
||||||
|
request_for_comments nil
|
||||||
|
type ""
|
||||||
|
end
|
||||||
|
end
|
7
test/models/subscription_test.rb
Normal file
7
test/models/subscription_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class SubscriptionTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Reference in New Issue
Block a user