Description:
add heart_beat
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

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
@@ -55,18 +55,20
55 # resources :products
55 # resources :products
56 # end
56 # end
57
57
58 # You can have the root of your site routed with "root"
58 # You can have the root of your site routed with "root"
59 # just remember to delete public/index.html.
59 # just remember to delete public/index.html.
60 # root :to => 'welcome#index'
60 # root :to => 'welcome#index'
61
61
62 root :to => 'main#login'
62 root :to => 'main#login'
63
63
64 match 'tasks/view/:file.:ext' => 'tasks#view'
64 match 'tasks/view/:file.:ext' => 'tasks#view'
65 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
65 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
66
66
67 + match 'heartbeat/:id/edit' => 'heartbeat#edit'
68 +
67 # See how all your routes lay out with "rake routes"
69 # See how all your routes lay out with "rake routes"
68
70
69 # This is a legacy wild controller route that's not recommended for RESTful applications.
71 # This is a legacy wild controller route that's not recommended for RESTful applications.
70 # Note: This route will make all actions in every controller accessible via GET requests.
72 # Note: This route will make all actions in every controller accessible via GET requests.
71 match ':controller(/:action(/:id))(.:format)'
73 match ':controller(/:action(/:id))(.:format)'
72 end
74 end
@@ -2,34 +2,34
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 to check this file into your version control system.
12 # It's strongly recommended to check this file into your version control system.
13
13
14 - ActiveRecord::Schema.define(:version => 20150827133841) do
14 + ActiveRecord::Schema.define(:version => 20150914090545) do
15
15
16 create_table "announcements", :force => true do |t|
16 create_table "announcements", :force => true do |t|
17 t.string "author"
17 t.string "author"
18 - t.text "body", :limit => 16777215
18 + t.text "body"
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"
24 t.string "title"
25 t.string "notes"
25 t.string "notes"
26 end
26 end
27
27
28 create_table "contests", :force => true do |t|
28 create_table "contests", :force => true do |t|
29 t.string "title"
29 t.string "title"
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"
33 t.string "name"
34 end
34 end
35
35
@@ -41,75 +41,82
41 create_table "contests_users", :id => false, :force => true do |t|
41 create_table "contests_users", :id => false, :force => true do |t|
42 t.integer "contest_id"
42 t.integer "contest_id"
43 t.integer "user_id"
43 t.integer "user_id"
44 end
44 end
45
45
46 create_table "countries", :force => true do |t|
46 create_table "countries", :force => true do |t|
47 t.string "name"
47 t.string "name"
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 => true do |t|
52 create_table "descriptions", :force => true do |t|
53 - t.text "body", :limit => 16777215
53 + t.text "body"
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 => true do |t|
59 create_table "grader_configurations", :force => true do |t|
60 t.string "key"
60 t.string "key"
61 t.string "value_type"
61 t.string "value_type"
62 t.string "value"
62 t.string "value"
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"
66 end
66 end
67
67
68 create_table "grader_processes", :force => true do |t|
68 create_table "grader_processes", :force => true do |t|
69 t.string "host", :limit => 20
69 t.string "host", :limit => 20
70 t.integer "pid"
70 t.integer "pid"
71 t.string "mode"
71 t.string "mode"
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"
75 t.integer "task_id"
76 t.string "task_type"
76 t.string "task_type"
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"
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 create_table "languages", :force => true do |t|
89 create_table "languages", :force => true do |t|
83 t.string "name", :limit => 10
90 t.string "name", :limit => 10
84 t.string "pretty_name"
91 t.string "pretty_name"
85 t.string "ext", :limit => 10
92 t.string "ext", :limit => 10
86 t.string "common_ext"
93 t.string "common_ext"
87 end
94 end
88
95
89 create_table "logins", :force => true do |t|
96 create_table "logins", :force => true do |t|
90 t.integer "user_id"
97 t.integer "user_id"
91 t.string "ip_address"
98 t.string "ip_address"
92 t.datetime "created_at", :null => false
99 t.datetime "created_at", :null => false
93 t.datetime "updated_at", :null => false
100 t.datetime "updated_at", :null => false
94 end
101 end
95
102
96 create_table "messages", :force => true do |t|
103 create_table "messages", :force => true do |t|
97 t.integer "sender_id"
104 t.integer "sender_id"
98 t.integer "receiver_id"
105 t.integer "receiver_id"
99 t.integer "replying_message_id"
106 t.integer "replying_message_id"
100 - t.text "body", :limit => 16777215
107 + t.text "body"
101 t.boolean "replied"
108 t.boolean "replied"
102 - t.datetime "created_at", :null => false
109 + t.datetime "created_at", :null => false
103 - t.datetime "updated_at", :null => false
110 + t.datetime "updated_at", :null => false
104 end
111 end
105
112
106 create_table "problems", :force => true do |t|
113 create_table "problems", :force => true do |t|
107 t.string "name", :limit => 30
114 t.string "name", :limit => 30
108 t.string "full_name"
115 t.string "full_name"
109 t.integer "full_score"
116 t.integer "full_score"
110 t.date "date_added"
117 t.date "date_added"
111 t.boolean "available"
118 t.boolean "available"
112 t.string "url"
119 t.string "url"
113 t.integer "description_id"
120 t.integer "description_id"
114 t.boolean "test_allowed"
121 t.boolean "test_allowed"
115 t.boolean "output_only"
122 t.boolean "output_only"
@@ -133,25 +140,25
133 t.string "name"
140 t.string "name"
134 end
141 end
135
142
136 create_table "roles_users", :id => false, :force => true do |t|
143 create_table "roles_users", :id => false, :force => true do |t|
137 t.integer "role_id"
144 t.integer "role_id"
138 t.integer "user_id"
145 t.integer "user_id"
139 end
146 end
140
147
141 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
148 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
142
149
143 create_table "sessions", :force => true do |t|
150 create_table "sessions", :force => true do |t|
144 t.string "session_id"
151 t.string "session_id"
145 - t.text "data", :limit => 16777215
152 + t.text "data"
146 t.datetime "updated_at"
153 t.datetime "updated_at"
147 end
154 end
148
155
149 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
156 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
150 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
157 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
151
158
152 create_table "sites", :force => true do |t|
159 create_table "sites", :force => true do |t|
153 t.string "name"
160 t.string "name"
154 t.boolean "started"
161 t.boolean "started"
155 t.datetime "start_time"
162 t.datetime "start_time"
156 t.datetime "created_at", :null => false
163 t.datetime "created_at", :null => false
157 t.datetime "updated_at", :null => false
164 t.datetime "updated_at", :null => false
@@ -161,73 +168,73
161
168
162 create_table "submission_view_logs", :force => true do |t|
169 create_table "submission_view_logs", :force => true do |t|
163 t.integer "user_id"
170 t.integer "user_id"
164 t.integer "submission_id"
171 t.integer "submission_id"
165 t.datetime "created_at", :null => false
172 t.datetime "created_at", :null => false
166 t.datetime "updated_at", :null => false
173 t.datetime "updated_at", :null => false
167 end
174 end
168
175
169 create_table "submissions", :force => true do |t|
176 create_table "submissions", :force => true do |t|
170 t.integer "user_id"
177 t.integer "user_id"
171 t.integer "problem_id"
178 t.integer "problem_id"
172 t.integer "language_id"
179 t.integer "language_id"
173 - t.text "source", :limit => 16777215
180 + t.text "source"
174 t.binary "binary"
181 t.binary "binary"
175 t.datetime "submitted_at"
182 t.datetime "submitted_at"
176 t.datetime "compiled_at"
183 t.datetime "compiled_at"
177 - t.text "compiler_message", :limit => 16777215
184 + t.text "compiler_message"
178 t.datetime "graded_at"
185 t.datetime "graded_at"
179 t.integer "points"
186 t.integer "points"
180 - t.text "grader_comment", :limit => 16777215
187 + t.text "grader_comment"
181 t.integer "number"
188 t.integer "number"
182 t.string "source_filename"
189 t.string "source_filename"
183 t.float "max_runtime"
190 t.float "max_runtime"
184 t.integer "peak_memory"
191 t.integer "peak_memory"
185 t.integer "effective_code_length"
192 t.integer "effective_code_length"
186 t.string "ip_address"
193 t.string "ip_address"
187 end
194 end
188
195
189 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
196 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
190 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
197 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
191
198
192 create_table "tasks", :force => true do |t|
199 create_table "tasks", :force => true do |t|
193 t.integer "submission_id"
200 t.integer "submission_id"
194 t.datetime "created_at"
201 t.datetime "created_at"
195 t.integer "status"
202 t.integer "status"
196 t.datetime "updated_at"
203 t.datetime "updated_at"
197 end
204 end
198
205
199 create_table "test_pairs", :force => true do |t|
206 create_table "test_pairs", :force => true do |t|
200 t.integer "problem_id"
207 t.integer "problem_id"
201 - t.text "input", :limit => 2147483647
208 + t.text "input", :limit => 16777215
202 - t.text "solution", :limit => 2147483647
209 + t.text "solution", :limit => 16777215
203 - t.datetime "created_at", :null => false
210 + t.datetime "created_at", :null => false
204 - t.datetime "updated_at", :null => false
211 + t.datetime "updated_at", :null => false
205 end
212 end
206
213
207 create_table "test_requests", :force => true do |t|
214 create_table "test_requests", :force => true do |t|
208 t.integer "user_id"
215 t.integer "user_id"
209 t.integer "problem_id"
216 t.integer "problem_id"
210 t.integer "submission_id"
217 t.integer "submission_id"
211 t.string "input_file_name"
218 t.string "input_file_name"
212 t.string "output_file_name"
219 t.string "output_file_name"
213 t.string "running_stat"
220 t.string "running_stat"
214 t.integer "status"
221 t.integer "status"
215 - t.datetime "updated_at", :null => false
222 + t.datetime "updated_at", :null => false
216 t.datetime "submitted_at"
223 t.datetime "submitted_at"
217 t.datetime "compiled_at"
224 t.datetime "compiled_at"
218 - t.text "compiler_message", :limit => 16777215
225 + t.text "compiler_message"
219 t.datetime "graded_at"
226 t.datetime "graded_at"
220 t.string "grader_comment"
227 t.string "grader_comment"
221 - t.datetime "created_at", :null => false
228 + t.datetime "created_at", :null => false
222 t.float "running_time"
229 t.float "running_time"
223 t.string "exit_status"
230 t.string "exit_status"
224 t.integer "memory_usage"
231 t.integer "memory_usage"
225 end
232 end
226
233
227 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
234 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
228
235
229 create_table "user_contest_stats", :force => true do |t|
236 create_table "user_contest_stats", :force => true do |t|
230 t.integer "user_id"
237 t.integer "user_id"
231 t.datetime "started_at"
238 t.datetime "started_at"
232 t.datetime "created_at", :null => false
239 t.datetime "created_at", :null => false
233 t.datetime "updated_at", :null => false
240 t.datetime "updated_at", :null => false
@@ -237,21 +244,21
237 create_table "users", :force => true do |t|
244 create_table "users", :force => true do |t|
238 t.string "login", :limit => 50
245 t.string "login", :limit => 50
239 t.string "full_name"
246 t.string "full_name"
240 t.string "hashed_password"
247 t.string "hashed_password"
241 t.string "salt", :limit => 5
248 t.string "salt", :limit => 5
242 t.string "alias"
249 t.string "alias"
243 t.string "email"
250 t.string "email"
244 t.integer "site_id"
251 t.integer "site_id"
245 t.integer "country_id"
252 t.integer "country_id"
246 t.boolean "activated", :default => false
253 t.boolean "activated", :default => false
247 t.datetime "created_at"
254 t.datetime "created_at"
248 t.datetime "updated_at"
255 t.datetime "updated_at"
249 - t.string "section"
250 t.boolean "enabled", :default => true
256 t.boolean "enabled", :default => true
251 t.string "remark"
257 t.string "remark"
252 t.string "last_ip"
258 t.string "last_ip"
259 + t.string "section"
253 end
260 end
254
261
255 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
262 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
256
263
257 end
264 end
You need to be logged in to leave comments. Login now