Description:
resize submissions.source field from "TEXT" to "MEDIUMTEXT"
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r712:04cb04cf3cfa - - 2 files changed: 29 inserted, 29 deleted

@@ -1,166 +1,166
1 class Submission < ActiveRecord::Base
1 class Submission < ActiveRecord::Base
2
2
3 belongs_to :language
3 belongs_to :language
4 belongs_to :problem
4 belongs_to :problem
5 belongs_to :user
5 belongs_to :user
6
6
7 before_validation :assign_problem
7 before_validation :assign_problem
8 before_validation :assign_language
8 before_validation :assign_language
9
9
10 validates_presence_of :source
10 validates_presence_of :source
11 - validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'too long'
11 + validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'code too long, the limit is 100,000 bytes'
12 validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short'
12 validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short'
13 validate :must_have_valid_problem
13 validate :must_have_valid_problem
14 validate :must_specify_language
14 validate :must_specify_language
15
15
16 has_one :task
16 has_one :task
17
17
18 before_save :assign_latest_number_if_new_recond
18 before_save :assign_latest_number_if_new_recond
19
19
20 def self.find_last_by_user_and_problem(user_id, problem_id)
20 def self.find_last_by_user_and_problem(user_id, problem_id)
21 where("user_id = ? AND problem_id = ?",user_id,problem_id).last
21 where("user_id = ? AND problem_id = ?",user_id,problem_id).last
22 end
22 end
23
23
24 def self.find_all_last_by_problem(problem_id)
24 def self.find_all_last_by_problem(problem_id)
25 # need to put in SQL command, maybe there's a better way
25 # need to put in SQL command, maybe there's a better way
26 Submission.includes(:user).find_by_sql("SELECT * FROM submissions " +
26 Submission.includes(:user).find_by_sql("SELECT * FROM submissions " +
27 "WHERE id = " +
27 "WHERE id = " +
28 "(SELECT MAX(id) FROM submissions AS subs " +
28 "(SELECT MAX(id) FROM submissions AS subs " +
29 "WHERE subs.user_id = submissions.user_id AND " +
29 "WHERE subs.user_id = submissions.user_id AND " +
30 "problem_id = " + problem_id.to_s + " " +
30 "problem_id = " + problem_id.to_s + " " +
31 "GROUP BY user_id) " +
31 "GROUP BY user_id) " +
32 "ORDER BY user_id")
32 "ORDER BY user_id")
33 end
33 end
34
34
35 def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id)
35 def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id)
36 records = Submission.where(problem_id: problem_id,user_id: user_id)
36 records = Submission.where(problem_id: problem_id,user_id: user_id)
37 records = records.where('id >= ?',since_id) if since_id and since_id > 0
37 records = records.where('id >= ?',since_id) if since_id and since_id > 0
38 records = records.where('id <= ?',until_id) if until_id and until_id > 0
38 records = records.where('id <= ?',until_id) if until_id and until_id > 0
39 records.all
39 records.all
40 end
40 end
41
41
42 def self.find_last_for_all_available_problems(user_id)
42 def self.find_last_for_all_available_problems(user_id)
43 submissions = Array.new
43 submissions = Array.new
44 problems = Problem.available_problems
44 problems = Problem.available_problems
45 problems.each do |problem|
45 problems.each do |problem|
46 sub = Submission.find_last_by_user_and_problem(user_id, problem.id)
46 sub = Submission.find_last_by_user_and_problem(user_id, problem.id)
47 submissions << sub if sub!=nil
47 submissions << sub if sub!=nil
48 end
48 end
49 submissions
49 submissions
50 end
50 end
51
51
52 def self.find_by_user_problem_number(user_id, problem_id, number)
52 def self.find_by_user_problem_number(user_id, problem_id, number)
53 where("user_id = ? AND problem_id = ? AND number = ?",user_id,problem_id,number).first
53 where("user_id = ? AND problem_id = ? AND number = ?",user_id,problem_id,number).first
54 end
54 end
55
55
56 def self.find_all_by_user_problem(user_id, problem_id)
56 def self.find_all_by_user_problem(user_id, problem_id)
57 where("user_id = ? AND problem_id = ?",user_id,problem_id)
57 where("user_id = ? AND problem_id = ?",user_id,problem_id)
58 end
58 end
59
59
60 def download_filename
60 def download_filename
61 if self.problem.output_only
61 if self.problem.output_only
62 return self.source_filename
62 return self.source_filename
63 else
63 else
64 timestamp = self.submitted_at.localtime.strftime("%H%M%S")
64 timestamp = self.submitted_at.localtime.strftime("%H%M%S")
65 return "#{self.problem.name}-#{timestamp}.#{self.language.ext}"
65 return "#{self.problem.name}-#{timestamp}.#{self.language.ext}"
66 end
66 end
67 end
67 end
68
68
69 protected
69 protected
70
70
71 def self.find_option_in_source(option, source)
71 def self.find_option_in_source(option, source)
72 if source==nil
72 if source==nil
73 return nil
73 return nil
74 end
74 end
75 i = 0
75 i = 0
76 source.each_line do |s|
76 source.each_line do |s|
77 if s =~ option
77 if s =~ option
78 words = s.split
78 words = s.split
79 return words[1]
79 return words[1]
80 end
80 end
81 i = i + 1
81 i = i + 1
82 if i==10
82 if i==10
83 return nil
83 return nil
84 end
84 end
85 end
85 end
86 return nil
86 return nil
87 end
87 end
88
88
89 def self.find_language_in_source(source, source_filename="")
89 def self.find_language_in_source(source, source_filename="")
90 langopt = find_option_in_source(/^LANG:/,source)
90 langopt = find_option_in_source(/^LANG:/,source)
91 if langopt
91 if langopt
92 return (Language.find_by_name(langopt) ||
92 return (Language.find_by_name(langopt) ||
93 Language.find_by_pretty_name(langopt))
93 Language.find_by_pretty_name(langopt))
94 else
94 else
95 if source_filename
95 if source_filename
96 return Language.find_by_extension(source_filename.split('.').last)
96 return Language.find_by_extension(source_filename.split('.').last)
97 else
97 else
98 return nil
98 return nil
99 end
99 end
100 end
100 end
101 end
101 end
102
102
103 def self.find_problem_in_source(source, source_filename="")
103 def self.find_problem_in_source(source, source_filename="")
104 prob_opt = find_option_in_source(/^TASK:/,source)
104 prob_opt = find_option_in_source(/^TASK:/,source)
105 if problem = Problem.find_by_name(prob_opt)
105 if problem = Problem.find_by_name(prob_opt)
106 return problem
106 return problem
107 else
107 else
108 if source_filename
108 if source_filename
109 return Problem.find_by_name(source_filename.split('.').first)
109 return Problem.find_by_name(source_filename.split('.').first)
110 else
110 else
111 return nil
111 return nil
112 end
112 end
113 end
113 end
114 end
114 end
115
115
116 def assign_problem
116 def assign_problem
117 if self.problem_id!=-1
117 if self.problem_id!=-1
118 begin
118 begin
119 self.problem = Problem.find(self.problem_id)
119 self.problem = Problem.find(self.problem_id)
120 rescue ActiveRecord::RecordNotFound
120 rescue ActiveRecord::RecordNotFound
121 self.problem = nil
121 self.problem = nil
122 end
122 end
123 else
123 else
124 self.problem = Submission.find_problem_in_source(self.source,
124 self.problem = Submission.find_problem_in_source(self.source,
125 self.source_filename)
125 self.source_filename)
126 end
126 end
127 end
127 end
128
128
129 def assign_language
129 def assign_language
130 self.language = Submission.find_language_in_source(self.source,
130 self.language = Submission.find_language_in_source(self.source,
131 self.source_filename)
131 self.source_filename)
132 end
132 end
133
133
134 # validation codes
134 # validation codes
135 def must_specify_language
135 def must_specify_language
136 return if self.source==nil
136 return if self.source==nil
137
137
138 # for output_only tasks
138 # for output_only tasks
139 return if self.problem!=nil and self.problem.output_only
139 return if self.problem!=nil and self.problem.output_only
140
140
141 if self.language==nil
141 if self.language==nil
142 errors.add('source',"Cannot detect language. Did you submit a correct source file?") unless self.language!=nil
142 errors.add('source',"Cannot detect language. Did you submit a correct source file?") unless self.language!=nil
143 end
143 end
144 end
144 end
145
145
146 def must_have_valid_problem
146 def must_have_valid_problem
147 return if self.source==nil
147 return if self.source==nil
148 if self.problem==nil
148 if self.problem==nil
149 errors.add('problem',"must be specified.")
149 errors.add('problem',"must be specified.")
150 else
150 else
151 #admin always have right
151 #admin always have right
152 return if self.user.admin?
152 return if self.user.admin?
153
153
154 #check if user has the right to submit the problem
154 #check if user has the right to submit the problem
155 errors.add('problem',"must be valid.") if (!self.user.available_problems.include?(self.problem)) and (self.new_record?)
155 errors.add('problem',"must be valid.") if (!self.user.available_problems.include?(self.problem)) and (self.new_record?)
156 end
156 end
157 end
157 end
158
158
159 # callbacks
159 # callbacks
160 def assign_latest_number_if_new_recond
160 def assign_latest_number_if_new_recond
161 return if !self.new_record?
161 return if !self.new_record?
162 latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id)
162 latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id)
163 self.number = (latest==nil) ? 1 : latest.number + 1;
163 self.number = (latest==nil) ? 1 : latest.number + 1;
164 end
164 end
165
165
166 end
166 end
@@ -1,321 +1,321
1 # encoding: UTF-8
1 # encoding: UTF-8
2 # This file is auto-generated from the current state of the database. Instead
2 # This file is auto-generated from the current state of the database. Instead
3 # of editing this file, please use the migrations feature of Active Record to
3 # of editing this file, please use the migrations feature of Active Record to
4 # incrementally modify your database, and then regenerate this schema definition.
4 # incrementally modify your database, and then regenerate this schema definition.
5 #
5 #
6 # Note that this schema.rb definition is the authoritative source for your
6 # Note that this schema.rb definition is the authoritative source for your
7 # database schema. If you need to create the application database on another
7 # database schema. If you need to create the application database on another
8 # system, you should be using db:schema:load, not running all the migrations
8 # system, you should be using db:schema:load, not running all the migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
11 #
11 #
12 # It's strongly recommended that you check this file into your version control system.
12 # It's strongly recommended that you check this file into your version control system.
13
13
14 - ActiveRecord::Schema.define(version: 20170914150742) do
14 + ActiveRecord::Schema.define(version: 20180612102327) do
15
15
16 create_table "announcements", force: :cascade do |t|
16 create_table "announcements", force: :cascade do |t|
17 t.string "author", limit: 255
17 t.string "author", limit: 255
18 - t.text "body", limit: 16777215
18 + t.text "body", limit: 65535
19 t.boolean "published"
19 t.boolean "published"
20 - t.datetime "created_at", null: false
20 + t.datetime "created_at", null: false
21 - t.datetime "updated_at", null: false
21 + t.datetime "updated_at", null: false
22 - t.boolean "frontpage", default: false
22 + t.boolean "frontpage", default: false
23 - t.boolean "contest_only", default: false
23 + t.boolean "contest_only", default: false
24 t.string "title", limit: 255
24 t.string "title", limit: 255
25 t.string "notes", limit: 255
25 t.string "notes", limit: 255
26 end
26 end
27
27
28 create_table "contests", force: :cascade do |t|
28 create_table "contests", force: :cascade do |t|
29 t.string "title", limit: 255
29 t.string "title", limit: 255
30 t.boolean "enabled"
30 t.boolean "enabled"
31 t.datetime "created_at", null: false
31 t.datetime "created_at", null: false
32 t.datetime "updated_at", null: false
32 t.datetime "updated_at", null: false
33 t.string "name", limit: 255
33 t.string "name", limit: 255
34 end
34 end
35
35
36 create_table "contests_problems", id: false, force: :cascade do |t|
36 create_table "contests_problems", id: false, force: :cascade do |t|
37 t.integer "contest_id", limit: 4
37 t.integer "contest_id", limit: 4
38 t.integer "problem_id", limit: 4
38 t.integer "problem_id", limit: 4
39 end
39 end
40
40
41 create_table "contests_users", id: false, force: :cascade do |t|
41 create_table "contests_users", id: false, force: :cascade do |t|
42 t.integer "contest_id", limit: 4
42 t.integer "contest_id", limit: 4
43 t.integer "user_id", limit: 4
43 t.integer "user_id", limit: 4
44 end
44 end
45
45
46 create_table "countries", force: :cascade do |t|
46 create_table "countries", force: :cascade do |t|
47 t.string "name", limit: 255
47 t.string "name", limit: 255
48 t.datetime "created_at", null: false
48 t.datetime "created_at", null: false
49 t.datetime "updated_at", null: false
49 t.datetime "updated_at", null: false
50 end
50 end
51
51
52 create_table "descriptions", force: :cascade do |t|
52 create_table "descriptions", force: :cascade do |t|
53 - t.text "body", limit: 16777215
53 + t.text "body", limit: 65535
54 t.boolean "markdowned"
54 t.boolean "markdowned"
55 - t.datetime "created_at", null: false
55 + t.datetime "created_at", null: false
56 - t.datetime "updated_at", null: false
56 + t.datetime "updated_at", null: false
57 end
57 end
58
58
59 create_table "grader_configurations", force: :cascade do |t|
59 create_table "grader_configurations", force: :cascade do |t|
60 t.string "key", limit: 255
60 t.string "key", limit: 255
61 t.string "value_type", limit: 255
61 t.string "value_type", limit: 255
62 t.string "value", limit: 255
62 t.string "value", limit: 255
63 - t.datetime "created_at", null: false
63 + t.datetime "created_at", null: false
64 - t.datetime "updated_at", null: false
64 + t.datetime "updated_at", null: false
65 - t.text "description", limit: 16777215
65 + t.text "description", limit: 65535
66 end
66 end
67
67
68 create_table "grader_processes", force: :cascade do |t|
68 create_table "grader_processes", force: :cascade do |t|
69 t.string "host", limit: 255
69 t.string "host", limit: 255
70 t.integer "pid", limit: 4
70 t.integer "pid", limit: 4
71 t.string "mode", limit: 255
71 t.string "mode", limit: 255
72 t.boolean "active"
72 t.boolean "active"
73 t.datetime "created_at", null: false
73 t.datetime "created_at", null: false
74 t.datetime "updated_at", null: false
74 t.datetime "updated_at", null: false
75 t.integer "task_id", limit: 4
75 t.integer "task_id", limit: 4
76 t.string "task_type", limit: 255
76 t.string "task_type", limit: 255
77 t.boolean "terminated"
77 t.boolean "terminated"
78 end
78 end
79
79
80 add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_ip_and_pid", using: :btree
80 add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_ip_and_pid", using: :btree
81
81
82 create_table "groups", force: :cascade do |t|
82 create_table "groups", force: :cascade do |t|
83 t.string "name", limit: 255
83 t.string "name", limit: 255
84 t.string "description", limit: 255
84 t.string "description", limit: 255
85 end
85 end
86
86
87 create_table "groups_problems", id: false, force: :cascade do |t|
87 create_table "groups_problems", id: false, force: :cascade do |t|
88 t.integer "problem_id", limit: 4, null: false
88 t.integer "problem_id", limit: 4, null: false
89 t.integer "group_id", limit: 4, null: false
89 t.integer "group_id", limit: 4, null: false
90 end
90 end
91
91
92 add_index "groups_problems", ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id", using: :btree
92 add_index "groups_problems", ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id", using: :btree
93
93
94 create_table "groups_users", id: false, force: :cascade do |t|
94 create_table "groups_users", id: false, force: :cascade do |t|
95 t.integer "group_id", limit: 4, null: false
95 t.integer "group_id", limit: 4, null: false
96 t.integer "user_id", limit: 4, null: false
96 t.integer "user_id", limit: 4, null: false
97 end
97 end
98
98
99 add_index "groups_users", ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id", using: :btree
99 add_index "groups_users", ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id", using: :btree
100
100
101 create_table "heart_beats", force: :cascade do |t|
101 create_table "heart_beats", force: :cascade do |t|
102 t.integer "user_id", limit: 4
102 t.integer "user_id", limit: 4
103 t.string "ip_address", limit: 255
103 t.string "ip_address", limit: 255
104 t.datetime "created_at", null: false
104 t.datetime "created_at", null: false
105 t.datetime "updated_at", null: false
105 t.datetime "updated_at", null: false
106 t.string "status", limit: 255
106 t.string "status", limit: 255
107 end
107 end
108
108
109 add_index "heart_beats", ["updated_at"], name: "index_heart_beats_on_updated_at", using: :btree
109 add_index "heart_beats", ["updated_at"], name: "index_heart_beats_on_updated_at", using: :btree
110
110
111 create_table "languages", force: :cascade do |t|
111 create_table "languages", force: :cascade do |t|
112 t.string "name", limit: 10
112 t.string "name", limit: 10
113 t.string "pretty_name", limit: 255
113 t.string "pretty_name", limit: 255
114 t.string "ext", limit: 10
114 t.string "ext", limit: 10
115 t.string "common_ext", limit: 255
115 t.string "common_ext", limit: 255
116 end
116 end
117
117
118 create_table "logins", force: :cascade do |t|
118 create_table "logins", force: :cascade do |t|
119 t.integer "user_id", limit: 4
119 t.integer "user_id", limit: 4
120 t.string "ip_address", limit: 255
120 t.string "ip_address", limit: 255
121 t.datetime "created_at", null: false
121 t.datetime "created_at", null: false
122 t.datetime "updated_at", null: false
122 t.datetime "updated_at", null: false
123 end
123 end
124
124
125 create_table "messages", force: :cascade do |t|
125 create_table "messages", force: :cascade do |t|
126 t.integer "sender_id", limit: 4
126 t.integer "sender_id", limit: 4
127 t.integer "receiver_id", limit: 4
127 t.integer "receiver_id", limit: 4
128 t.integer "replying_message_id", limit: 4
128 t.integer "replying_message_id", limit: 4
129 - t.text "body", limit: 16777215
129 + t.text "body", limit: 65535
130 t.boolean "replied"
130 t.boolean "replied"
131 - t.datetime "created_at", null: false
131 + t.datetime "created_at", null: false
132 - t.datetime "updated_at", null: false
132 + t.datetime "updated_at", null: false
133 end
133 end
134
134
135 create_table "problems", force: :cascade do |t|
135 create_table "problems", force: :cascade do |t|
136 t.string "name", limit: 30
136 t.string "name", limit: 30
137 t.string "full_name", limit: 255
137 t.string "full_name", limit: 255
138 t.integer "full_score", limit: 4
138 t.integer "full_score", limit: 4
139 t.date "date_added"
139 t.date "date_added"
140 t.boolean "available"
140 t.boolean "available"
141 t.string "url", limit: 255
141 t.string "url", limit: 255
142 t.integer "description_id", limit: 4
142 t.integer "description_id", limit: 4
143 t.boolean "test_allowed"
143 t.boolean "test_allowed"
144 t.boolean "output_only"
144 t.boolean "output_only"
145 t.string "description_filename", limit: 255
145 t.string "description_filename", limit: 255
146 t.boolean "view_testcase"
146 t.boolean "view_testcase"
147 end
147 end
148
148
149 create_table "problems_tags", force: :cascade do |t|
149 create_table "problems_tags", force: :cascade do |t|
150 t.integer "problem_id", limit: 4
150 t.integer "problem_id", limit: 4
151 t.integer "tag_id", limit: 4
151 t.integer "tag_id", limit: 4
152 end
152 end
153
153
154 add_index "problems_tags", ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true, using: :btree
154 add_index "problems_tags", ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true, using: :btree
155 add_index "problems_tags", ["problem_id"], name: "index_problems_tags_on_problem_id", using: :btree
155 add_index "problems_tags", ["problem_id"], name: "index_problems_tags_on_problem_id", using: :btree
156 add_index "problems_tags", ["tag_id"], name: "index_problems_tags_on_tag_id", using: :btree
156 add_index "problems_tags", ["tag_id"], name: "index_problems_tags_on_tag_id", using: :btree
157
157
158 create_table "rights", force: :cascade do |t|
158 create_table "rights", force: :cascade do |t|
159 t.string "name", limit: 255
159 t.string "name", limit: 255
160 t.string "controller", limit: 255
160 t.string "controller", limit: 255
161 t.string "action", limit: 255
161 t.string "action", limit: 255
162 end
162 end
163
163
164 create_table "rights_roles", id: false, force: :cascade do |t|
164 create_table "rights_roles", id: false, force: :cascade do |t|
165 t.integer "right_id", limit: 4
165 t.integer "right_id", limit: 4
166 t.integer "role_id", limit: 4
166 t.integer "role_id", limit: 4
167 end
167 end
168
168
169 add_index "rights_roles", ["role_id"], name: "index_rights_roles_on_role_id", using: :btree
169 add_index "rights_roles", ["role_id"], name: "index_rights_roles_on_role_id", using: :btree
170
170
171 create_table "roles", force: :cascade do |t|
171 create_table "roles", force: :cascade do |t|
172 t.string "name", limit: 255
172 t.string "name", limit: 255
173 end
173 end
174
174
175 create_table "roles_users", id: false, force: :cascade do |t|
175 create_table "roles_users", id: false, force: :cascade do |t|
176 t.integer "role_id", limit: 4
176 t.integer "role_id", limit: 4
177 t.integer "user_id", limit: 4
177 t.integer "user_id", limit: 4
178 end
178 end
179
179
180 add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id", using: :btree
180 add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id", using: :btree
181
181
182 create_table "sessions", force: :cascade do |t|
182 create_table "sessions", force: :cascade do |t|
183 t.string "session_id", limit: 255
183 t.string "session_id", limit: 255
184 - t.text "data", limit: 16777215
184 + t.text "data", limit: 65535
185 t.datetime "updated_at"
185 t.datetime "updated_at"
186 end
186 end
187
187
188 add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree
188 add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree
189 add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
189 add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
190
190
191 create_table "sites", force: :cascade do |t|
191 create_table "sites", force: :cascade do |t|
192 t.string "name", limit: 255
192 t.string "name", limit: 255
193 t.boolean "started"
193 t.boolean "started"
194 t.datetime "start_time"
194 t.datetime "start_time"
195 t.datetime "created_at", null: false
195 t.datetime "created_at", null: false
196 t.datetime "updated_at", null: false
196 t.datetime "updated_at", null: false
197 t.integer "country_id", limit: 4
197 t.integer "country_id", limit: 4
198 t.string "password", limit: 255
198 t.string "password", limit: 255
199 end
199 end
200
200
201 create_table "submission_view_logs", force: :cascade do |t|
201 create_table "submission_view_logs", force: :cascade do |t|
202 t.integer "user_id", limit: 4
202 t.integer "user_id", limit: 4
203 t.integer "submission_id", limit: 4
203 t.integer "submission_id", limit: 4
204 t.datetime "created_at", null: false
204 t.datetime "created_at", null: false
205 t.datetime "updated_at", null: false
205 t.datetime "updated_at", null: false
206 end
206 end
207
207
208 create_table "submissions", force: :cascade do |t|
208 create_table "submissions", force: :cascade do |t|
209 t.integer "user_id", limit: 4
209 t.integer "user_id", limit: 4
210 t.integer "problem_id", limit: 4
210 t.integer "problem_id", limit: 4
211 t.integer "language_id", limit: 4
211 t.integer "language_id", limit: 4
212 t.text "source", limit: 16777215
212 t.text "source", limit: 16777215
213 t.binary "binary", limit: 65535
213 t.binary "binary", limit: 65535
214 t.datetime "submitted_at"
214 t.datetime "submitted_at"
215 t.datetime "compiled_at"
215 t.datetime "compiled_at"
216 - t.text "compiler_message", limit: 16777215
216 + t.text "compiler_message", limit: 65535
217 t.datetime "graded_at"
217 t.datetime "graded_at"
218 t.integer "points", limit: 4
218 t.integer "points", limit: 4
219 - t.text "grader_comment", limit: 16777215
219 + t.text "grader_comment", limit: 65535
220 t.integer "number", limit: 4
220 t.integer "number", limit: 4
221 t.string "source_filename", limit: 255
221 t.string "source_filename", limit: 255
222 t.float "max_runtime", limit: 24
222 t.float "max_runtime", limit: 24
223 t.integer "peak_memory", limit: 4
223 t.integer "peak_memory", limit: 4
224 t.integer "effective_code_length", limit: 4
224 t.integer "effective_code_length", limit: 4
225 t.string "ip_address", limit: 255
225 t.string "ip_address", limit: 255
226 end
226 end
227
227
228 add_index "submissions", ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true, using: :btree
228 add_index "submissions", ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true, using: :btree
229 add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree
229 add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree
230
230
231 create_table "tags", force: :cascade do |t|
231 create_table "tags", force: :cascade do |t|
232 t.string "name", limit: 255, null: false
232 t.string "name", limit: 255, null: false
233 t.text "description", limit: 65535
233 t.text "description", limit: 65535
234 t.boolean "public"
234 t.boolean "public"
235 t.datetime "created_at", null: false
235 t.datetime "created_at", null: false
236 t.datetime "updated_at", null: false
236 t.datetime "updated_at", null: false
237 end
237 end
238
238
239 create_table "tasks", force: :cascade do |t|
239 create_table "tasks", force: :cascade do |t|
240 t.integer "submission_id", limit: 4
240 t.integer "submission_id", limit: 4
241 t.datetime "created_at"
241 t.datetime "created_at"
242 t.integer "status", limit: 4
242 t.integer "status", limit: 4
243 t.datetime "updated_at"
243 t.datetime "updated_at"
244 end
244 end
245
245
246 add_index "tasks", ["submission_id"], name: "index_tasks_on_submission_id", using: :btree
246 add_index "tasks", ["submission_id"], name: "index_tasks_on_submission_id", using: :btree
247
247
248 create_table "test_pairs", force: :cascade do |t|
248 create_table "test_pairs", force: :cascade do |t|
249 t.integer "problem_id", limit: 4
249 t.integer "problem_id", limit: 4
250 - t.text "input", limit: 4294967295
250 + t.text "input", limit: 16777215
251 - t.text "solution", limit: 4294967295
251 + t.text "solution", limit: 16777215
252 - t.datetime "created_at", null: false
252 + t.datetime "created_at", null: false
253 - t.datetime "updated_at", null: false
253 + t.datetime "updated_at", null: false
254 end
254 end
255
255
256 create_table "test_requests", force: :cascade do |t|
256 create_table "test_requests", force: :cascade do |t|
257 t.integer "user_id", limit: 4
257 t.integer "user_id", limit: 4
258 t.integer "problem_id", limit: 4
258 t.integer "problem_id", limit: 4
259 t.integer "submission_id", limit: 4
259 t.integer "submission_id", limit: 4
260 t.string "input_file_name", limit: 255
260 t.string "input_file_name", limit: 255
261 t.string "output_file_name", limit: 255
261 t.string "output_file_name", limit: 255
262 t.string "running_stat", limit: 255
262 t.string "running_stat", limit: 255
263 t.integer "status", limit: 4
263 t.integer "status", limit: 4
264 - t.datetime "updated_at", null: false
264 + t.datetime "updated_at", null: false
265 t.datetime "submitted_at"
265 t.datetime "submitted_at"
266 t.datetime "compiled_at"
266 t.datetime "compiled_at"
267 - t.text "compiler_message", limit: 16777215
267 + t.text "compiler_message", limit: 65535
268 t.datetime "graded_at"
268 t.datetime "graded_at"
269 t.string "grader_comment", limit: 255
269 t.string "grader_comment", limit: 255
270 - t.datetime "created_at", null: false
270 + t.datetime "created_at", null: false
271 t.float "running_time", limit: 24
271 t.float "running_time", limit: 24
272 t.string "exit_status", limit: 255
272 t.string "exit_status", limit: 255
273 t.integer "memory_usage", limit: 4
273 t.integer "memory_usage", limit: 4
274 end
274 end
275
275
276 add_index "test_requests", ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id", using: :btree
276 add_index "test_requests", ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id", using: :btree
277
277
278 create_table "testcases", force: :cascade do |t|
278 create_table "testcases", force: :cascade do |t|
279 t.integer "problem_id", limit: 4
279 t.integer "problem_id", limit: 4
280 t.integer "num", limit: 4
280 t.integer "num", limit: 4
281 t.integer "group", limit: 4
281 t.integer "group", limit: 4
282 t.integer "score", limit: 4
282 t.integer "score", limit: 4
283 t.text "input", limit: 4294967295
283 t.text "input", limit: 4294967295
284 t.text "sol", limit: 4294967295
284 t.text "sol", limit: 4294967295
285 - t.datetime "created_at", null: false
285 + t.datetime "created_at"
286 - t.datetime "updated_at", null: false
286 + t.datetime "updated_at"
287 end
287 end
288
288
289 add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree
289 add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree
290
290
291 create_table "user_contest_stats", force: :cascade do |t|
291 create_table "user_contest_stats", force: :cascade do |t|
292 t.integer "user_id", limit: 4
292 t.integer "user_id", limit: 4
293 t.datetime "started_at"
293 t.datetime "started_at"
294 t.datetime "created_at", null: false
294 t.datetime "created_at", null: false
295 t.datetime "updated_at", null: false
295 t.datetime "updated_at", null: false
296 t.boolean "forced_logout"
296 t.boolean "forced_logout"
297 end
297 end
298
298
299 create_table "users", force: :cascade do |t|
299 create_table "users", force: :cascade do |t|
300 t.string "login", limit: 50
300 t.string "login", limit: 50
301 t.string "full_name", limit: 255
301 t.string "full_name", limit: 255
302 t.string "hashed_password", limit: 255
302 t.string "hashed_password", limit: 255
303 t.string "salt", limit: 5
303 t.string "salt", limit: 5
304 t.string "alias", limit: 255
304 t.string "alias", limit: 255
305 t.string "email", limit: 255
305 t.string "email", limit: 255
306 t.integer "site_id", limit: 4
306 t.integer "site_id", limit: 4
307 t.integer "country_id", limit: 4
307 t.integer "country_id", limit: 4
308 t.boolean "activated", default: false
308 t.boolean "activated", default: false
309 t.datetime "created_at"
309 t.datetime "created_at"
310 t.datetime "updated_at"
310 t.datetime "updated_at"
311 - t.string "section", limit: 255
312 t.boolean "enabled", default: true
311 t.boolean "enabled", default: true
313 t.string "remark", limit: 255
312 t.string "remark", limit: 255
314 t.string "last_ip", limit: 255
313 t.string "last_ip", limit: 255
314 + t.string "section", limit: 255
315 end
315 end
316
316
317 add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree
317 add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree
318
318
319 add_foreign_key "problems_tags", "problems"
319 add_foreign_key "problems_tags", "problems"
320 add_foreign_key "problems_tags", "tags"
320 add_foreign_key "problems_tags", "tags"
321 end
321 end
You need to be logged in to leave comments. Login now