Description:
keep all heartbeat instead of only the latest one
(grafted from 0bdf62fde5fdb94d6f94c2b8b8ebc58ffbe8d2f9)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r544:63ac076b653a - - 2 files changed: 24 inserted, 23 deleted
@@ -1,29 +1,30 | |||
|
1 | 1 | class HeartbeatController < ApplicationController |
|
2 | 2 | before_filter :admin_authorization, :only => ['index'] |
|
3 | 3 | |
|
4 | 4 | def edit |
|
5 | 5 | @user = User.find_by_login(params[:id]) |
|
6 | 6 | unless @user |
|
7 | 7 | render text: "LOGIN_NOT_FOUND" |
|
8 | 8 | return |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | - hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first | |
|
12 | - puts "status = #{params[:status]}" | |
|
13 | - if hb | |
|
14 | - if params[:status] | |
|
15 | - hb.status = params[:status] | |
|
16 | - hb.save | |
|
17 | - end | |
|
18 | - hb.touch | |
|
19 | - else | |
|
20 | - HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) | |
|
21 | - end | |
|
11 | + #hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first | |
|
12 | + #puts "status = #{params[:status]}" | |
|
13 | + #if hb | |
|
14 | + # if params[:status] | |
|
15 | + # hb.status = params[:status] | |
|
16 | + # hb.save | |
|
17 | + # end | |
|
18 | + # hb.touch | |
|
19 | + #else | |
|
20 | + # HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) | |
|
21 | + #end | |
|
22 | + HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) | |
|
22 | 23 | render text: "OK" |
|
23 | 24 | end |
|
24 | 25 | |
|
25 | 26 | def index |
|
26 | 27 | @hb = HeartBeat.includes(:user).order(:user_id).all |
|
27 | 28 | @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count |
|
28 | 29 | end |
|
29 | 30 | end |
@@ -1,265 +1,265 | |||
|
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 to check this file into your version control system. |
|
13 | 13 | |
|
14 | 14 | ActiveRecord::Schema.define(:version => 20150914223258) 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 | 20 |
t.datetime "created_at", |
|
21 | 21 |
t.datetime "updated_at", |
|
22 | 22 |
t.boolean "frontpage", |
|
23 | 23 |
t.boolean "contest_only", |
|
24 | 24 | t.string "title" |
|
25 | 25 | t.string "notes" |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | create_table "contests", :force => true do |t| |
|
29 | 29 | t.string "title" |
|
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" |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | create_table "contests_problems", :id => false, :force => true do |t| |
|
37 | 37 | t.integer "contest_id" |
|
38 | 38 | t.integer "problem_id" |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | create_table "contests_users", :id => false, :force => true do |t| |
|
42 | 42 | t.integer "contest_id" |
|
43 | 43 | t.integer "user_id" |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | create_table "countries", :force => true do |t| |
|
47 | 47 | t.string "name" |
|
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 => true do |t| |
|
53 |
- t.text "body" |
|
|
53 | + t.text "body" | |
|
54 | 54 | t.boolean "markdowned" |
|
55 | 55 |
t.datetime "created_at", |
|
56 | 56 |
t.datetime "updated_at", |
|
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 | 63 |
t.datetime "created_at", |
|
64 | 64 |
t.datetime "updated_at", |
|
65 |
- t.text "description" |
|
|
65 | + t.text "description" | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | create_table "grader_processes", :force => true do |t| |
|
69 | 69 | t.string "host", :limit => 20 |
|
70 | 70 | t.integer "pid" |
|
71 | 71 | t.string "mode" |
|
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" |
|
76 | 76 | t.string "task_type" |
|
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" |
|
81 | 81 | |
|
82 | 82 | create_table "heart_beats", :force => true do |t| |
|
83 | 83 | t.integer "user_id" |
|
84 | 84 | t.string "ip_address" |
|
85 | 85 | t.datetime "created_at", :null => false |
|
86 | 86 | t.datetime "updated_at", :null => false |
|
87 | 87 | t.string "status" |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | create_table "languages", :force => true do |t| |
|
91 | 91 | t.string "name", :limit => 10 |
|
92 | 92 | t.string "pretty_name" |
|
93 | 93 | t.string "ext", :limit => 10 |
|
94 | 94 | t.string "common_ext" |
|
95 | 95 | end |
|
96 | 96 | |
|
97 | 97 | create_table "logins", :force => true do |t| |
|
98 | 98 | t.integer "user_id" |
|
99 | 99 | t.string "ip_address" |
|
100 | 100 | t.datetime "created_at", :null => false |
|
101 | 101 | t.datetime "updated_at", :null => false |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | create_table "messages", :force => true do |t| |
|
105 | 105 | t.integer "sender_id" |
|
106 | 106 | t.integer "receiver_id" |
|
107 | 107 | t.integer "replying_message_id" |
|
108 | - t.text "body", :limit => 16777215 | |
|
108 | + t.text "body" | |
|
109 | 109 | t.boolean "replied" |
|
110 | 110 |
t.datetime "created_at", |
|
111 | 111 |
t.datetime "updated_at", |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | create_table "problems", :force => true do |t| |
|
115 | 115 | t.string "name", :limit => 30 |
|
116 | 116 | t.string "full_name" |
|
117 | 117 | t.integer "full_score" |
|
118 | 118 | t.date "date_added" |
|
119 | 119 | t.boolean "available" |
|
120 | 120 | t.string "url" |
|
121 | 121 | t.integer "description_id" |
|
122 | 122 | t.boolean "test_allowed" |
|
123 | 123 | t.boolean "output_only" |
|
124 | 124 | t.string "description_filename" |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | create_table "rights", :force => true do |t| |
|
128 | 128 | t.string "name" |
|
129 | 129 | t.string "controller" |
|
130 | 130 | t.string "action" |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | create_table "rights_roles", :id => false, :force => true do |t| |
|
134 | 134 | t.integer "right_id" |
|
135 | 135 | t.integer "role_id" |
|
136 | 136 | end |
|
137 | 137 | |
|
138 | 138 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
139 | 139 | |
|
140 | 140 | create_table "roles", :force => true do |t| |
|
141 | 141 | t.string "name" |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | create_table "roles_users", :id => false, :force => true do |t| |
|
145 | 145 | t.integer "role_id" |
|
146 | 146 | t.integer "user_id" |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
150 | 150 | |
|
151 | 151 | create_table "sessions", :force => true do |t| |
|
152 | 152 | t.string "session_id" |
|
153 |
- t.text "data" |
|
|
153 | + t.text "data" | |
|
154 | 154 | t.datetime "updated_at" |
|
155 | 155 | end |
|
156 | 156 | |
|
157 | 157 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
158 | 158 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
159 | 159 | |
|
160 | 160 | create_table "sites", :force => true do |t| |
|
161 | 161 | t.string "name" |
|
162 | 162 | t.boolean "started" |
|
163 | 163 | t.datetime "start_time" |
|
164 | 164 | t.datetime "created_at", :null => false |
|
165 | 165 | t.datetime "updated_at", :null => false |
|
166 | 166 | t.integer "country_id" |
|
167 | 167 | t.string "password" |
|
168 | 168 | end |
|
169 | 169 | |
|
170 | 170 | create_table "submission_view_logs", :force => true do |t| |
|
171 | 171 | t.integer "user_id" |
|
172 | 172 | t.integer "submission_id" |
|
173 | 173 | t.datetime "created_at", :null => false |
|
174 | 174 | t.datetime "updated_at", :null => false |
|
175 | 175 | end |
|
176 | 176 | |
|
177 | 177 | create_table "submissions", :force => true do |t| |
|
178 | 178 | t.integer "user_id" |
|
179 | 179 | t.integer "problem_id" |
|
180 | 180 | t.integer "language_id" |
|
181 | - t.text "source", :limit => 16777215 | |
|
181 | + t.text "source" | |
|
182 | 182 | t.binary "binary" |
|
183 | 183 | t.datetime "submitted_at" |
|
184 | 184 | t.datetime "compiled_at" |
|
185 |
- t.text "compiler_message" |
|
|
185 | + t.text "compiler_message" | |
|
186 | 186 | t.datetime "graded_at" |
|
187 | 187 | t.integer "points" |
|
188 |
- t.text "grader_comment" |
|
|
188 | + t.text "grader_comment" | |
|
189 | 189 | t.integer "number" |
|
190 | 190 | t.string "source_filename" |
|
191 | 191 | t.float "max_runtime" |
|
192 | 192 | t.integer "peak_memory" |
|
193 | 193 | t.integer "effective_code_length" |
|
194 | 194 | t.string "ip_address" |
|
195 | 195 | end |
|
196 | 196 | |
|
197 | 197 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
198 | 198 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
199 | 199 | |
|
200 | 200 | create_table "tasks", :force => true do |t| |
|
201 | 201 | t.integer "submission_id" |
|
202 | 202 | t.datetime "created_at" |
|
203 | 203 | t.integer "status" |
|
204 | 204 | t.datetime "updated_at" |
|
205 | 205 | end |
|
206 | 206 | |
|
207 | 207 | create_table "test_pairs", :force => true do |t| |
|
208 | 208 | t.integer "problem_id" |
|
209 |
- t.text "input", :limit => |
|
|
210 |
- t.text "solution", :limit => |
|
|
209 | + t.text "input", :limit => 16777215 | |
|
210 | + t.text "solution", :limit => 16777215 | |
|
211 | 211 |
t.datetime "created_at", |
|
212 | 212 |
t.datetime "updated_at", |
|
213 | 213 | end |
|
214 | 214 | |
|
215 | 215 | create_table "test_requests", :force => true do |t| |
|
216 | 216 | t.integer "user_id" |
|
217 | 217 | t.integer "problem_id" |
|
218 | 218 | t.integer "submission_id" |
|
219 | 219 | t.string "input_file_name" |
|
220 | 220 | t.string "output_file_name" |
|
221 | 221 | t.string "running_stat" |
|
222 | 222 | t.integer "status" |
|
223 | 223 |
t.datetime "updated_at", |
|
224 | 224 | t.datetime "submitted_at" |
|
225 | 225 | t.datetime "compiled_at" |
|
226 |
- t.text "compiler_message" |
|
|
226 | + t.text "compiler_message" | |
|
227 | 227 | t.datetime "graded_at" |
|
228 | 228 | t.string "grader_comment" |
|
229 | 229 |
t.datetime "created_at", |
|
230 | 230 | t.float "running_time" |
|
231 | 231 | t.string "exit_status" |
|
232 | 232 | t.integer "memory_usage" |
|
233 | 233 | end |
|
234 | 234 | |
|
235 | 235 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
236 | 236 | |
|
237 | 237 | create_table "user_contest_stats", :force => true do |t| |
|
238 | 238 | t.integer "user_id" |
|
239 | 239 | t.datetime "started_at" |
|
240 | 240 | t.datetime "created_at", :null => false |
|
241 | 241 | t.datetime "updated_at", :null => false |
|
242 | 242 | t.boolean "forced_logout" |
|
243 | 243 | end |
|
244 | 244 | |
|
245 | 245 | create_table "users", :force => true do |t| |
|
246 | 246 | t.string "login", :limit => 50 |
|
247 | 247 | t.string "full_name" |
|
248 | 248 | t.string "hashed_password" |
|
249 | 249 | t.string "salt", :limit => 5 |
|
250 | 250 | t.string "alias" |
|
251 | 251 | t.string "email" |
|
252 | 252 | t.integer "site_id" |
|
253 | 253 | t.integer "country_id" |
|
254 | 254 | t.boolean "activated", :default => false |
|
255 | 255 | t.datetime "created_at" |
|
256 | 256 | t.datetime "updated_at" |
|
257 | - t.string "section" | |
|
258 | 257 | t.boolean "enabled", :default => true |
|
259 | 258 | t.string "remark" |
|
260 | 259 | t.string "last_ip" |
|
260 | + t.string "section" | |
|
261 | 261 | end |
|
262 | 262 | |
|
263 | 263 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
264 | 264 | |
|
265 | 265 | end |
You need to be logged in to leave comments.
Login now