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

r540:7fdec87758d5 - - 6 files changed: 42 inserted, 1 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
@@ -19,54 +19,56
19 19 # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
20 20 # This route can be invoked with purchase_url(:id => product.id)
21 21
22 22 # Sample resource route (maps HTTP verbs to controller actions automatically):
23 23 # resources :products
24 24
25 25 # Sample resource route with options:
26 26 # resources :products do
27 27 # member do
28 28 # get 'short'
29 29 # post 'toggle'
30 30 # end
31 31 #
32 32 # collection do
33 33 # get 'sold'
34 34 # end
35 35 # end
36 36
37 37 # Sample resource route with sub-resources:
38 38 # resources :products do
39 39 # resources :comments, :sales
40 40 # resource :seller
41 41 # end
42 42
43 43 # Sample resource route with more complex sub-resources
44 44 # resources :products do
45 45 # resources :comments
46 46 # resources :sales do
47 47 # get 'recent', :on => :collection
48 48 # end
49 49 # end
50 50
51 51 # Sample resource route within a namespace:
52 52 # namespace :admin do
53 53 # # Directs /admin/products/* to Admin::ProductsController
54 54 # # (app/controllers/admin/products_controller.rb)
55 55 # resources :products
56 56 # end
57 57
58 58 # You can have the root of your site routed with "root"
59 59 # just remember to delete public/index.html.
60 60 # root :to => 'welcome#index'
61 61
62 62 root :to => 'main#login'
63 63
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.
70 72 # Note: This route will make all actions in every controller accessible via GET requests.
71 73 match ':controller(/:action(/:id))(.:format)'
72 74 end
@@ -1,129 +1,136
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 - ActiveRecord::Schema.define(:version => 20150827133841) do
14 + ActiveRecord::Schema.define(:version => 20150914090545) do
15 15
16 16 create_table "announcements", :force => true do |t|
17 17 t.string "author"
18 18 t.text "body"
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"
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 53 t.text "body"
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 => 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", :null => false
64 64 t.datetime "updated_at", :null => false
65 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 + 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"
85 92 t.string "ext", :limit => 10
86 93 t.string "common_ext"
87 94 end
88 95
89 96 create_table "logins", :force => true do |t|
90 97 t.integer "user_id"
91 98 t.string "ip_address"
92 99 t.datetime "created_at", :null => false
93 100 t.datetime "updated_at", :null => false
94 101 end
95 102
96 103 create_table "messages", :force => true do |t|
97 104 t.integer "sender_id"
98 105 t.integer "receiver_id"
99 106 t.integer "replying_message_id"
100 107 t.text "body"
101 108 t.boolean "replied"
102 109 t.datetime "created_at", :null => false
103 110 t.datetime "updated_at", :null => false
104 111 end
105 112
106 113 create_table "problems", :force => true do |t|
107 114 t.string "name", :limit => 30
108 115 t.string "full_name"
109 116 t.integer "full_score"
110 117 t.date "date_added"
111 118 t.boolean "available"
112 119 t.string "url"
113 120 t.integer "description_id"
114 121 t.boolean "test_allowed"
115 122 t.boolean "output_only"
116 123 t.string "description_filename"
117 124 end
118 125
119 126 create_table "rights", :force => true do |t|
120 127 t.string "name"
121 128 t.string "controller"
122 129 t.string "action"
123 130 end
124 131
125 132 create_table "rights_roles", :id => false, :force => true do |t|
126 133 t.integer "right_id"
127 134 t.integer "role_id"
128 135 end
129 136
@@ -204,53 +211,54
204 211 t.datetime "updated_at", :null => false
205 212 end
206 213
207 214 create_table "test_requests", :force => true do |t|
208 215 t.integer "user_id"
209 216 t.integer "problem_id"
210 217 t.integer "submission_id"
211 218 t.string "input_file_name"
212 219 t.string "output_file_name"
213 220 t.string "running_stat"
214 221 t.integer "status"
215 222 t.datetime "updated_at", :null => false
216 223 t.datetime "submitted_at"
217 224 t.datetime "compiled_at"
218 225 t.text "compiler_message"
219 226 t.datetime "graded_at"
220 227 t.string "grader_comment"
221 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"
225 232 end
226 233
227 234 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
228 235
229 236 create_table "user_contest_stats", :force => true do |t|
230 237 t.integer "user_id"
231 238 t.datetime "started_at"
232 239 t.datetime "created_at", :null => false
233 240 t.datetime "updated_at", :null => false
234 241 t.boolean "forced_logout"
235 242 end
236 243
237 244 create_table "users", :force => true do |t|
238 245 t.string "login", :limit => 50
239 246 t.string "full_name"
240 247 t.string "hashed_password"
241 248 t.string "salt", :limit => 5
242 249 t.string "alias"
243 250 t.string "email"
244 251 t.integer "site_id"
245 252 t.integer "country_id"
246 253 t.boolean "activated", :default => false
247 254 t.datetime "created_at"
248 255 t.datetime "updated_at"
249 256 t.boolean "enabled", :default => true
250 257 t.string "remark"
251 258 t.string "last_ip"
259 + t.string "section"
252 260 end
253 261
254 262 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
255 263
256 264 end
You need to be logged in to leave comments. Login now