Description:
add heart_beat
(grafted from baf0af002308b84f920a384166b4265c82124159)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
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 |
@@ -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,7 +11,7 | |||
|
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" |
@@ -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" |
@@ -249,6 +256,7 | |||
|
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 |
You need to be logged in to leave comments.
Login now