Description:
add heart_beat
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r533:1e7bcdbe3dcb - - 6 files changed: 67 inserted, 27 deleted
@@ -0,0 +1,14 | |||
|
1 | + class HeartbeatController < ApplicationController | |
|
2 | + def edit | |
|
3 | + render layout: 'empty' | |
|
4 | + @user = User.find_by_login(params[:id]) | |
|
5 | + return unless @user | |
|
6 | + | |
|
7 | + hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first | |
|
8 | + if hb | |
|
9 | + hb.touch | |
|
10 | + else | |
|
11 | + HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip) | |
|
12 | + end | |
|
13 | + end | |
|
14 | + end |
@@ -0,0 +1,6 | |||
|
1 | + class HeartBeat < ActiveRecord::Base | |
|
2 | + # attr_accessible :title, :body | |
|
3 | + belongs_to :user | |
|
4 | + | |
|
5 | + #attr_accessible :ip_address | |
|
6 | + end |
@@ -0,0 +1,1 | |||
|
1 | + OK |
@@ -0,0 +1,10 | |||
|
1 | + class CreateHeartBeats < ActiveRecord::Migration | |
|
2 | + def change | |
|
3 | + create_table :heart_beats do |t| | |
|
4 | + t.column 'user_id',:integer | |
|
5 | + t.column 'ip_address',:string | |
|
6 | + | |
|
7 | + t.timestamps | |
|
8 | + end | |
|
9 | + end | |
|
10 | + end |
@@ -64,6 +64,8 | |||
|
64 | 64 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
65 | 65 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
66 | 66 | |
|
67 | + match 'heartbeat/:id/edit' => 'heartbeat#edit' | |
|
68 | + | |
|
67 | 69 | # See how all your routes lay out with "rake routes" |
|
68 | 70 | |
|
69 | 71 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
@@ -11,16 +11,16 | |||
|
11 | 11 | # |
|
12 | 12 | # It's strongly recommended to check this file into your version control system. |
|
13 | 13 | |
|
14 |
- ActiveRecord::Schema.define(:version => 20150 |
|
|
14 | + ActiveRecord::Schema.define(:version => 20150914090545) do | |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", :force => true do |t| |
|
17 | 17 | t.string "author" |
|
18 |
- t.text "body" |
|
|
18 | + t.text "body" | |
|
19 | 19 | t.boolean "published" |
|
20 |
- t.datetime "created_at", |
|
|
21 |
- t.datetime "updated_at", |
|
|
22 |
- t.boolean "frontpage", |
|
|
23 |
- t.boolean "contest_only", |
|
|
20 | + t.datetime "created_at", :null => false | |
|
21 | + t.datetime "updated_at", :null => false | |
|
22 | + t.boolean "frontpage", :default => false | |
|
23 | + t.boolean "contest_only", :default => false | |
|
24 | 24 | t.string "title" |
|
25 | 25 | t.string "notes" |
|
26 | 26 | end |
@@ -50,19 +50,19 | |||
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | create_table "descriptions", :force => true do |t| |
|
53 |
- t.text "body" |
|
|
53 | + t.text "body" | |
|
54 | 54 | t.boolean "markdowned" |
|
55 |
- t.datetime "created_at", |
|
|
56 |
- t.datetime "updated_at", |
|
|
55 | + t.datetime "created_at", :null => false | |
|
56 | + t.datetime "updated_at", :null => false | |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | create_table "grader_configurations", :force => true do |t| |
|
60 | 60 | t.string "key" |
|
61 | 61 | t.string "value_type" |
|
62 | 62 | t.string "value" |
|
63 |
- t.datetime "created_at", |
|
|
64 |
- t.datetime "updated_at", |
|
|
65 |
- t.text "description" |
|
|
63 | + t.datetime "created_at", :null => false | |
|
64 | + t.datetime "updated_at", :null => false | |
|
65 | + t.text "description" | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | create_table "grader_processes", :force => true do |t| |
@@ -79,6 +79,13 | |||
|
79 | 79 | |
|
80 | 80 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
81 | 81 | |
|
82 | + create_table "heart_beats", :force => true do |t| | |
|
83 | + t.integer "user_id" | |
|
84 | + t.string "ip_address" | |
|
85 | + t.datetime "created_at", :null => false | |
|
86 | + t.datetime "updated_at", :null => false | |
|
87 | + end | |
|
88 | + | |
|
82 | 89 | create_table "languages", :force => true do |t| |
|
83 | 90 | t.string "name", :limit => 10 |
|
84 | 91 | t.string "pretty_name" |
@@ -97,10 +104,10 | |||
|
97 | 104 | t.integer "sender_id" |
|
98 | 105 | t.integer "receiver_id" |
|
99 | 106 | t.integer "replying_message_id" |
|
100 | - t.text "body", :limit => 16777215 | |
|
107 | + t.text "body" | |
|
101 | 108 | t.boolean "replied" |
|
102 |
- t.datetime "created_at", |
|
|
103 |
- t.datetime "updated_at", |
|
|
109 | + t.datetime "created_at", :null => false | |
|
110 | + t.datetime "updated_at", :null => false | |
|
104 | 111 | end |
|
105 | 112 | |
|
106 | 113 | create_table "problems", :force => true do |t| |
@@ -142,7 +149,7 | |||
|
142 | 149 | |
|
143 | 150 | create_table "sessions", :force => true do |t| |
|
144 | 151 | t.string "session_id" |
|
145 |
- t.text "data" |
|
|
152 | + t.text "data" | |
|
146 | 153 | t.datetime "updated_at" |
|
147 | 154 | end |
|
148 | 155 | |
@@ -170,14 +177,14 | |||
|
170 | 177 | t.integer "user_id" |
|
171 | 178 | t.integer "problem_id" |
|
172 | 179 | t.integer "language_id" |
|
173 | - t.text "source", :limit => 16777215 | |
|
180 | + t.text "source" | |
|
174 | 181 | t.binary "binary" |
|
175 | 182 | t.datetime "submitted_at" |
|
176 | 183 | t.datetime "compiled_at" |
|
177 |
- t.text "compiler_message" |
|
|
184 | + t.text "compiler_message" | |
|
178 | 185 | t.datetime "graded_at" |
|
179 | 186 | t.integer "points" |
|
180 |
- t.text "grader_comment" |
|
|
187 | + t.text "grader_comment" | |
|
181 | 188 | t.integer "number" |
|
182 | 189 | t.string "source_filename" |
|
183 | 190 | t.float "max_runtime" |
@@ -198,10 +205,10 | |||
|
198 | 205 | |
|
199 | 206 | create_table "test_pairs", :force => true do |t| |
|
200 | 207 | t.integer "problem_id" |
|
201 |
- t.text "input", :limit => |
|
|
202 |
- t.text "solution", :limit => |
|
|
203 |
- t.datetime "created_at", |
|
|
204 |
- t.datetime "updated_at", |
|
|
208 | + t.text "input", :limit => 16777215 | |
|
209 | + t.text "solution", :limit => 16777215 | |
|
210 | + t.datetime "created_at", :null => false | |
|
211 | + t.datetime "updated_at", :null => false | |
|
205 | 212 | end |
|
206 | 213 | |
|
207 | 214 | create_table "test_requests", :force => true do |t| |
@@ -212,13 +219,13 | |||
|
212 | 219 | t.string "output_file_name" |
|
213 | 220 | t.string "running_stat" |
|
214 | 221 | t.integer "status" |
|
215 |
- t.datetime "updated_at", |
|
|
222 | + t.datetime "updated_at", :null => false | |
|
216 | 223 | t.datetime "submitted_at" |
|
217 | 224 | t.datetime "compiled_at" |
|
218 |
- t.text "compiler_message" |
|
|
225 | + t.text "compiler_message" | |
|
219 | 226 | t.datetime "graded_at" |
|
220 | 227 | t.string "grader_comment" |
|
221 |
- t.datetime "created_at", |
|
|
228 | + t.datetime "created_at", :null => false | |
|
222 | 229 | t.float "running_time" |
|
223 | 230 | t.string "exit_status" |
|
224 | 231 | t.integer "memory_usage" |
@@ -246,10 +253,10 | |||
|
246 | 253 | t.boolean "activated", :default => false |
|
247 | 254 | t.datetime "created_at" |
|
248 | 255 | t.datetime "updated_at" |
|
249 | - t.string "section" | |
|
250 | 256 | t.boolean "enabled", :default => true |
|
251 | 257 | t.string "remark" |
|
252 | 258 | t.string "last_ip" |
|
259 | + t.string "section" | |
|
253 | 260 | end |
|
254 | 261 | |
|
255 | 262 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
You need to be logged in to leave comments.
Login now