Description:
update
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r684:11ce8d963587 - - 2 files changed: 15 inserted, 14 deleted
@@ -93,48 +93,49 | |||
|
93 | 93 | def retrieve_password |
|
94 | 94 | email = params[:email] |
|
95 | 95 | user = User.find_by_email(email) |
|
96 | 96 | if user |
|
97 | 97 | last_updated_time = user.updated_at || user.created_at || (Time.now.gmtime - 1.hour) |
|
98 | 98 | if last_updated_time > Time.now.gmtime - 5.minutes |
|
99 | 99 | flash[:notice] = 'The account has recently created or new password has recently been requested. Please wait for 5 minutes' |
|
100 | 100 | else |
|
101 | 101 | user.password = user.password_confirmation = User.random_password |
|
102 | 102 | user.save |
|
103 | 103 | send_new_password_email(user) |
|
104 | 104 | flash[:notice] = 'New password has been mailed to you.' |
|
105 | 105 | end |
|
106 | 106 | else |
|
107 | 107 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
108 | 108 | end |
|
109 | 109 | redirect_to :action => 'forget' |
|
110 | 110 | end |
|
111 | 111 | |
|
112 | 112 | def stat |
|
113 | 113 | @user = User.find(params[:id]) |
|
114 | 114 | @submission = Submission.joins(:problem).where(user_id: params[:id]) |
|
115 | 115 | @submission = @submission.where('problems.available = true') unless current_user.admin? |
|
116 | 116 | |
|
117 | + | |
|
117 | 118 | range = 120 |
|
118 | 119 | @histogram = { data: Array.new(range,0), summary: {} } |
|
119 | 120 | @summary = {count: 0, solve: 0, attempt: 0} |
|
120 | 121 | problem = Hash.new(0) |
|
121 | 122 | |
|
122 | 123 | @submission.find_each do |sub| |
|
123 | 124 | #histogram |
|
124 | 125 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
125 | 126 | @histogram[:data][d.to_i] += 1 if d < range |
|
126 | 127 | |
|
127 | 128 | @summary[:count] += 1 |
|
128 | 129 | next unless sub.problem |
|
129 | 130 | problem[sub.problem] = [problem[sub.problem], ( (sub.try(:points) || 0) >= sub.problem.full_score) ? 1 : 0].max |
|
130 | 131 | end |
|
131 | 132 | |
|
132 | 133 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
133 | 134 | @summary[:attempt] = problem.count |
|
134 | 135 | problem.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
135 | 136 | end |
|
136 | 137 | |
|
137 | 138 | def toggle_activate |
|
138 | 139 | @user = User.find(params[:id]) |
|
139 | 140 | @user.update_attributes( activated: !@user.activated? ) |
|
140 | 141 | respond_to do |format| |
@@ -1,283 +1,283 | |||
|
1 | 1 | # encoding: UTF-8 |
|
2 | 2 | # This file is auto-generated from the current state of the database. Instead |
|
3 | 3 | # of editing this file, please use the migrations feature of Active Record to |
|
4 | 4 | # incrementally modify your database, and then regenerate this schema definition. |
|
5 | 5 | # |
|
6 | 6 | # Note that this schema.rb definition is the authoritative source for your |
|
7 | 7 | # database schema. If you need to create the application database on another |
|
8 | 8 | # system, you should be using db:schema:load, not running all the migrations |
|
9 | 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
10 | 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
11 | 11 | # |
|
12 | 12 | # It's strongly recommended that you check this file into your version control system. |
|
13 | 13 | |
|
14 | 14 | ActiveRecord::Schema.define(version: 20170427070345) do |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", force: :cascade do |t| |
|
17 | 17 | t.string "author", limit: 255 |
|
18 |
- t.text "body", limit: |
|
|
18 | + t.text "body", limit: 16777215 | |
|
19 | 19 | t.boolean "published" |
|
20 | 20 | t.datetime "created_at", null: false |
|
21 | 21 | t.datetime "updated_at", null: false |
|
22 | 22 | t.boolean "frontpage", default: false |
|
23 | 23 | t.boolean "contest_only", default: false |
|
24 | 24 | t.string "title", limit: 255 |
|
25 | 25 | t.string "notes", limit: 255 |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | create_table "contests", force: :cascade do |t| |
|
29 | 29 | t.string "title", limit: 255 |
|
30 | 30 | t.boolean "enabled" |
|
31 | 31 | t.datetime "created_at", null: false |
|
32 | 32 | t.datetime "updated_at", null: false |
|
33 | 33 | t.string "name", limit: 255 |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | create_table "contests_problems", id: false, force: :cascade do |t| |
|
37 | 37 | t.integer "contest_id", limit: 4 |
|
38 | 38 | t.integer "problem_id", limit: 4 |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | create_table "contests_users", id: false, force: :cascade do |t| |
|
42 | 42 | t.integer "contest_id", limit: 4 |
|
43 | 43 | t.integer "user_id", limit: 4 |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | create_table "countries", force: :cascade do |t| |
|
47 | 47 | t.string "name", limit: 255 |
|
48 | 48 | t.datetime "created_at", null: false |
|
49 | 49 | t.datetime "updated_at", null: false |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | create_table "descriptions", force: :cascade do |t| |
|
53 |
- t.text "body", limit: |
|
|
53 | + t.text "body", limit: 16777215 | |
|
54 | 54 | t.boolean "markdowned" |
|
55 | 55 | t.datetime "created_at", null: false |
|
56 | 56 | t.datetime "updated_at", null: false |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | create_table "grader_configurations", force: :cascade do |t| |
|
60 | 60 | t.string "key", limit: 255 |
|
61 | 61 | t.string "value_type", limit: 255 |
|
62 | 62 | t.string "value", limit: 255 |
|
63 | 63 | t.datetime "created_at", null: false |
|
64 | 64 | t.datetime "updated_at", null: false |
|
65 |
- t.text "description", limit: |
|
|
65 | + t.text "description", limit: 16777215 | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | create_table "grader_processes", force: :cascade do |t| |
|
69 | 69 | t.string "host", limit: 255 |
|
70 | 70 | t.integer "pid", limit: 4 |
|
71 | 71 | t.string "mode", limit: 255 |
|
72 | 72 | t.boolean "active" |
|
73 | 73 | t.datetime "created_at", null: false |
|
74 | 74 | t.datetime "updated_at", null: false |
|
75 | 75 | t.integer "task_id", limit: 4 |
|
76 | 76 | t.string "task_type", limit: 255 |
|
77 | 77 | t.boolean "terminated" |
|
78 | 78 | end |
|
79 | 79 | |
|
80 | 80 | add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_ip_and_pid", using: :btree |
|
81 | 81 | |
|
82 | 82 | create_table "heart_beats", force: :cascade do |t| |
|
83 | 83 | t.integer "user_id", limit: 4 |
|
84 | 84 | t.string "ip_address", limit: 255 |
|
85 | 85 | t.datetime "created_at", null: false |
|
86 | 86 | t.datetime "updated_at", null: false |
|
87 | 87 | t.string "status", limit: 255 |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | add_index "heart_beats", ["updated_at"], name: "index_heart_beats_on_updated_at", using: :btree |
|
91 | 91 | |
|
92 | 92 | create_table "languages", force: :cascade do |t| |
|
93 | 93 | t.string "name", limit: 10 |
|
94 | 94 | t.string "pretty_name", limit: 255 |
|
95 | 95 | t.string "ext", limit: 10 |
|
96 | 96 | t.string "common_ext", limit: 255 |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | create_table "logins", force: :cascade do |t| |
|
100 | 100 | t.integer "user_id", limit: 4 |
|
101 | 101 | t.string "ip_address", limit: 255 |
|
102 | 102 | t.datetime "created_at", null: false |
|
103 | 103 | t.datetime "updated_at", null: false |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | create_table "messages", force: :cascade do |t| |
|
107 | 107 | t.integer "sender_id", limit: 4 |
|
108 | 108 | t.integer "receiver_id", limit: 4 |
|
109 | 109 | t.integer "replying_message_id", limit: 4 |
|
110 |
- t.text "body", limit: |
|
|
110 | + t.text "body", limit: 16777215 | |
|
111 | 111 | t.boolean "replied" |
|
112 | 112 | t.datetime "created_at", null: false |
|
113 | 113 | t.datetime "updated_at", null: false |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | create_table "problems", force: :cascade do |t| |
|
117 | 117 | t.string "name", limit: 30 |
|
118 | 118 | t.string "full_name", limit: 255 |
|
119 | 119 | t.integer "full_score", limit: 4 |
|
120 | 120 | t.date "date_added" |
|
121 | 121 | t.boolean "available" |
|
122 | 122 | t.string "url", limit: 255 |
|
123 | 123 | t.integer "description_id", limit: 4 |
|
124 | 124 | t.boolean "test_allowed" |
|
125 | 125 | t.boolean "output_only" |
|
126 | 126 | t.string "description_filename", limit: 255 |
|
127 | 127 | t.boolean "view_testcase" |
|
128 | 128 | end |
|
129 | 129 | |
|
130 | 130 | create_table "rights", force: :cascade do |t| |
|
131 | 131 | t.string "name", limit: 255 |
|
132 | 132 | t.string "controller", limit: 255 |
|
133 | 133 | t.string "action", limit: 255 |
|
134 | 134 | end |
|
135 | 135 | |
|
136 | 136 | create_table "rights_roles", id: false, force: :cascade do |t| |
|
137 | 137 | t.integer "right_id", limit: 4 |
|
138 | 138 | t.integer "role_id", limit: 4 |
|
139 | 139 | end |
|
140 | 140 | |
|
141 | 141 | add_index "rights_roles", ["role_id"], name: "index_rights_roles_on_role_id", using: :btree |
|
142 | 142 | |
|
143 | 143 | create_table "roles", force: :cascade do |t| |
|
144 | 144 | t.string "name", limit: 255 |
|
145 | 145 | end |
|
146 | 146 | |
|
147 | 147 | create_table "roles_users", id: false, force: :cascade do |t| |
|
148 | 148 | t.integer "role_id", limit: 4 |
|
149 | 149 | t.integer "user_id", limit: 4 |
|
150 | 150 | end |
|
151 | 151 | |
|
152 | 152 | add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id", using: :btree |
|
153 | 153 | |
|
154 | 154 | create_table "sessions", force: :cascade do |t| |
|
155 | 155 | t.string "session_id", limit: 255 |
|
156 |
- t.text "data", limit: |
|
|
156 | + t.text "data", limit: 16777215 | |
|
157 | 157 | t.datetime "updated_at" |
|
158 | 158 | end |
|
159 | 159 | |
|
160 | 160 | add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree |
|
161 | 161 | add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree |
|
162 | 162 | |
|
163 | 163 | create_table "sites", force: :cascade do |t| |
|
164 | 164 | t.string "name", limit: 255 |
|
165 | 165 | t.boolean "started" |
|
166 | 166 | t.datetime "start_time" |
|
167 | 167 | t.datetime "created_at", null: false |
|
168 | 168 | t.datetime "updated_at", null: false |
|
169 | 169 | t.integer "country_id", limit: 4 |
|
170 | 170 | t.string "password", limit: 255 |
|
171 | 171 | end |
|
172 | 172 | |
|
173 | 173 | create_table "submission_view_logs", force: :cascade do |t| |
|
174 | 174 | t.integer "user_id", limit: 4 |
|
175 | 175 | t.integer "submission_id", limit: 4 |
|
176 | 176 | t.datetime "created_at", null: false |
|
177 | 177 | t.datetime "updated_at", null: false |
|
178 | 178 | end |
|
179 | 179 | |
|
180 | 180 | create_table "submissions", force: :cascade do |t| |
|
181 | 181 | t.integer "user_id", limit: 4 |
|
182 | 182 | t.integer "problem_id", limit: 4 |
|
183 | 183 | t.integer "language_id", limit: 4 |
|
184 |
- t.text "source", limit: |
|
|
184 | + t.text "source", limit: 16777215 | |
|
185 | 185 | t.binary "binary", limit: 65535 |
|
186 | 186 | t.datetime "submitted_at" |
|
187 | 187 | t.datetime "compiled_at" |
|
188 |
- t.text "compiler_message", limit: |
|
|
188 | + t.text "compiler_message", limit: 16777215 | |
|
189 | 189 | t.datetime "graded_at" |
|
190 | 190 | t.integer "points", limit: 4 |
|
191 |
- t.text "grader_comment", limit: |
|
|
191 | + t.text "grader_comment", limit: 16777215 | |
|
192 | 192 | t.integer "number", limit: 4 |
|
193 | 193 | t.string "source_filename", limit: 255 |
|
194 | 194 | t.float "max_runtime", limit: 24 |
|
195 | 195 | t.integer "peak_memory", limit: 4 |
|
196 | 196 | t.integer "effective_code_length", limit: 4 |
|
197 | 197 | t.string "ip_address", limit: 255 |
|
198 | 198 | end |
|
199 | 199 | |
|
200 | 200 | add_index "submissions", ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true, using: :btree |
|
201 | 201 | add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id", using: :btree |
|
202 | 202 | |
|
203 | 203 | create_table "tasks", force: :cascade do |t| |
|
204 | 204 | t.integer "submission_id", limit: 4 |
|
205 | 205 | t.datetime "created_at" |
|
206 | 206 | t.integer "status", limit: 4 |
|
207 | 207 | t.datetime "updated_at" |
|
208 | 208 | end |
|
209 | 209 | |
|
210 | 210 | add_index "tasks", ["submission_id"], name: "index_tasks_on_submission_id", using: :btree |
|
211 | 211 | |
|
212 | 212 | create_table "test_pairs", force: :cascade do |t| |
|
213 | 213 | t.integer "problem_id", limit: 4 |
|
214 |
- t.text "input", limit: |
|
|
215 |
- t.text "solution", limit: |
|
|
214 | + t.text "input", limit: 4294967295 | |
|
215 | + t.text "solution", limit: 4294967295 | |
|
216 | 216 | t.datetime "created_at", null: false |
|
217 | 217 | t.datetime "updated_at", null: false |
|
218 | 218 | end |
|
219 | 219 | |
|
220 | 220 | create_table "test_requests", force: :cascade do |t| |
|
221 | 221 | t.integer "user_id", limit: 4 |
|
222 | 222 | t.integer "problem_id", limit: 4 |
|
223 | 223 | t.integer "submission_id", limit: 4 |
|
224 | 224 | t.string "input_file_name", limit: 255 |
|
225 | 225 | t.string "output_file_name", limit: 255 |
|
226 | 226 | t.string "running_stat", limit: 255 |
|
227 | 227 | t.integer "status", limit: 4 |
|
228 | 228 | t.datetime "updated_at", null: false |
|
229 | 229 | t.datetime "submitted_at" |
|
230 | 230 | t.datetime "compiled_at" |
|
231 |
- t.text "compiler_message", limit: |
|
|
231 | + t.text "compiler_message", limit: 16777215 | |
|
232 | 232 | t.datetime "graded_at" |
|
233 | 233 | t.string "grader_comment", limit: 255 |
|
234 | 234 | t.datetime "created_at", null: false |
|
235 | 235 | t.float "running_time", limit: 24 |
|
236 | 236 | t.string "exit_status", limit: 255 |
|
237 | 237 | t.integer "memory_usage", limit: 4 |
|
238 | 238 | end |
|
239 | 239 | |
|
240 | 240 | add_index "test_requests", ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id", using: :btree |
|
241 | 241 | |
|
242 | 242 | create_table "testcases", force: :cascade do |t| |
|
243 | 243 | t.integer "problem_id", limit: 4 |
|
244 | 244 | t.integer "num", limit: 4 |
|
245 | 245 | t.integer "group", limit: 4 |
|
246 | 246 | t.integer "score", limit: 4 |
|
247 | 247 | t.text "input", limit: 4294967295 |
|
248 | 248 | t.text "sol", limit: 4294967295 |
|
249 | - t.datetime "created_at" | |
|
250 | - t.datetime "updated_at" | |
|
249 | + t.datetime "created_at", null: false | |
|
250 | + t.datetime "updated_at", null: false | |
|
251 | 251 | end |
|
252 | 252 | |
|
253 | 253 | add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree |
|
254 | 254 | |
|
255 | 255 | create_table "user_contest_stats", force: :cascade do |t| |
|
256 | 256 | t.integer "user_id", limit: 4 |
|
257 | 257 | t.datetime "started_at" |
|
258 | 258 | t.datetime "created_at", null: false |
|
259 | 259 | t.datetime "updated_at", null: false |
|
260 | 260 | t.boolean "forced_logout" |
|
261 | 261 | end |
|
262 | 262 | |
|
263 | 263 | create_table "users", force: :cascade do |t| |
|
264 | 264 | t.string "login", limit: 50 |
|
265 | 265 | t.string "full_name", limit: 255 |
|
266 | 266 | t.string "hashed_password", limit: 255 |
|
267 | 267 | t.string "salt", limit: 5 |
|
268 | 268 | t.string "alias", limit: 255 |
|
269 | 269 | t.string "email", limit: 255 |
|
270 | 270 | t.integer "site_id", limit: 4 |
|
271 | 271 | t.integer "country_id", limit: 4 |
|
272 | 272 | t.boolean "activated", default: false |
|
273 | 273 | t.datetime "created_at" |
|
274 | 274 | t.datetime "updated_at" |
|
275 | + t.string "section", limit: 255 | |
|
275 | 276 | t.boolean "enabled", default: true |
|
276 | 277 | t.string "remark", limit: 255 |
|
277 | 278 | t.string "last_ip", limit: 255 |
|
278 | - t.string "section", limit: 255 | |
|
279 | 279 | end |
|
280 | 280 | |
|
281 | 281 | add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree |
|
282 | 282 | |
|
283 | 283 | end |
You need to be logged in to leave comments.
Login now