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 |
@@ -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,25 +2,25 | |||||
|
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 => 20150 |
|
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" |
|
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 |
@@ -70,24 +70,31 | |||||
|
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 |
@@ -240,17 +247,18 | |||||
|
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.boolean "enabled", :default => true |
|
256 | t.boolean "enabled", :default => true |
|
250 | t.string "remark" |
|
257 | t.string "remark" |
|
251 | t.string "last_ip" |
|
258 | t.string "last_ip" |
|
|
259 | + t.string "section" | ||
|
252 | end |
|
260 | end |
|
253 |
|
261 | ||
|
254 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
262 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
255 |
|
263 | ||
|
256 | end |
|
264 | end |
You need to be logged in to leave comments.
Login now