Description:
more heart beat feature
add reset last login ip
(grafted from 6efa41a1cfdc5e910b85eec6d8b874ed651776bd)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r541:11c20f65a6b8 - - 7 files changed: 92 inserted, 33 deleted
@@ -0,0 +1,30 | |||||
|
|
1 | + - content_for :header do | ||
|
|
2 | + = javascript_include_tag 'local_jquery' | ||
|
|
3 | + = stylesheet_link_tag 'tablesorter-theme.cafe' | ||
|
|
4 | + | ||
|
|
5 | + %script{:type=>"text/javascript"} | ||
|
|
6 | + $(function () { | ||
|
|
7 | + $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); | ||
|
|
8 | + $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); | ||
|
|
9 | + $('#my_table').tablesorter({widgets: ['zebra']}); | ||
|
|
10 | + }); | ||
|
|
11 | + | ||
|
|
12 | + %h1 Heart Beat Count | ||
|
|
13 | + = "Last 5 minutes distinct user count = #{@num}" | ||
|
|
14 | + | ||
|
|
15 | + %h1 Heart Beat List | ||
|
|
16 | + | ||
|
|
17 | + %table.tablesorter-cafe#my_table | ||
|
|
18 | + %thead | ||
|
|
19 | + %tr | ||
|
|
20 | + %th Login | ||
|
|
21 | + %th Full name | ||
|
|
22 | + %th IP | ||
|
|
23 | + %th Last Update | ||
|
|
24 | + %tbody | ||
|
|
25 | + - @hb.each do |hb| | ||
|
|
26 | + %tr{class: cycle('info-even','info-odd')} | ||
|
|
27 | + %td= link_to hb.user.login, controller: :users, :action => 'profile', :id => hb.user.id | ||
|
|
28 | + %td= hb.user.full_name | ||
|
|
29 | + %td= hb.ip_address | ||
|
|
30 | + %td= "#{time_ago_in_words(hb.updated_at)} ago" |
@@ -0,0 +1,5 | |||||
|
|
1 | + class AddStatusToHeartBeat < ActiveRecord::Migration | ||
|
|
2 | + def change | ||
|
|
3 | + add_column :heart_beats, :status, :string | ||
|
|
4 | + end | ||
|
|
5 | + end |
@@ -1,14 +1,29 | |||||
|
1 | class HeartbeatController < ApplicationController |
|
1 | class HeartbeatController < ApplicationController |
|
|
2 | + before_filter :admin_authorization, :only => ['index'] | ||
|
|
3 | + | ||
|
2 | def edit |
|
4 | def edit |
|
3 | - render layout: 'empty' |
|
||
|
4 | @user = User.find_by_login(params[:id]) |
|
5 | @user = User.find_by_login(params[:id]) |
|
5 |
- |
|
6 | + unless @user |
|
6 | - |
|
7 | + render text: "LOGIN_NOT_FOUND" |
|
|
8 | + return | ||
|
|
9 | + end | ||
|
|
10 | + | ||
|
7 | hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first |
|
11 | hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first |
|
|
12 | + puts "status = #{params[:status]}" | ||
|
8 | if hb |
|
13 | if hb |
|
|
14 | + if params[:status] | ||
|
|
15 | + hb.status = params[:status] | ||
|
|
16 | + hb.save | ||
|
|
17 | + end | ||
|
9 | hb.touch |
|
18 | hb.touch |
|
10 | else |
|
19 | else |
|
11 |
- HeartBeat.crea |
|
20 | + HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) |
|
12 | end |
|
21 | end |
|
|
22 | + render text: "OK" | ||
|
|
23 | + end | ||
|
|
24 | + | ||
|
|
25 | + def index | ||
|
|
26 | + @hb = HeartBeat.includes(:user).order(:user_id).all | ||
|
|
27 | + @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count | ||
|
13 | end |
|
28 | end |
|
14 | end |
|
29 | end |
@@ -59,12 +59,19 | |||||
|
59 | redirect_to :action => 'list' |
|
59 | redirect_to :action => 'list' |
|
60 | else |
|
60 | else |
|
61 | render :action => 'new' |
|
61 | render :action => 'new' |
|
62 | end |
|
62 | end |
|
63 | end |
|
63 | end |
|
64 |
|
64 | ||
|
|
65 | + def clear_last_ip | ||
|
|
66 | + @user = User.find(params[:id]) | ||
|
|
67 | + @user.last_ip = nil | ||
|
|
68 | + @user.save | ||
|
|
69 | + redirect_to action: 'list', page: params[:page] | ||
|
|
70 | + end | ||
|
|
71 | + | ||
|
65 | def create_from_list |
|
72 | def create_from_list |
|
66 | lines = params[:user_list] |
|
73 | lines = params[:user_list] |
|
67 |
|
74 | ||
|
68 | note = [] |
|
75 | note = [] |
|
69 |
|
76 | ||
|
70 | lines.split("\n").each do |line| |
|
77 | lines.split("\n").each do |line| |
@@ -210,13 +217,13 | |||||
|
210 | user.password_confirmation = password |
|
217 | user.password_confirmation = password |
|
211 | user.save |
|
218 | user.save |
|
212 | end |
|
219 | end |
|
213 | @changed = true |
|
220 | @changed = true |
|
214 | end |
|
221 | end |
|
215 | end |
|
222 | end |
|
216 | - |
|
223 | + |
|
217 | # contest management |
|
224 | # contest management |
|
218 |
|
225 | ||
|
219 | def contests |
|
226 | def contests |
|
220 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
227 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
221 | @contests = Contest.enabled |
|
228 | @contests = Contest.enabled |
|
222 | end |
|
229 | end |
@@ -61,22 +61,24 | |||||
|
61 | <th><%= column.human_name %></th> |
|
61 | <th><%= column.human_name %></th> |
|
62 | <% end %> |
|
62 | <% end %> |
|
63 | <% end %> |
|
63 | <% end %> |
|
64 | <th></th> |
|
64 | <th></th> |
|
65 | <th></th> |
|
65 | <th></th> |
|
66 | <th></th> |
|
66 | <th></th> |
|
|
67 | + <th></th> | ||
|
67 | </tr> |
|
68 | </tr> |
|
68 |
|
69 | ||
|
69 | <% for user in @users %> |
|
70 | <% for user in @users %> |
|
70 | <tr class="info-<%= cycle("odd","even") %>"> |
|
71 | <tr class="info-<%= cycle("odd","even") %>"> |
|
71 | <td><%= link_to user.login, controller: :users, :action => 'profile', :id => user %></td> |
|
72 | <td><%= link_to user.login, controller: :users, :action => 'profile', :id => user %></td> |
|
72 | <% for column in User.content_columns %> |
|
73 | <% for column in User.content_columns %> |
|
73 | <% if !@hidden_columns.index(column.name) and column.name != 'login' %> |
|
74 | <% if !@hidden_columns.index(column.name) and column.name != 'login' %> |
|
74 | <td><%=h user.send(column.name) %></td> |
|
75 | <td><%=h user.send(column.name) %></td> |
|
75 | <% end %> |
|
76 | <% end %> |
|
76 | <% end %> |
|
77 | <% end %> |
|
|
78 | + <td><%= link_to 'Clear IP', {:action => 'clear_last_ip', :id => user, :page=>params[:page]}, :confirm => 'This will reset last logging in ip of the user, are you sure?' %></td> | ||
|
77 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
79 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
78 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
80 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
79 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
81 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
80 | </tr> |
|
82 | </tr> |
|
81 | <% end %> |
|
83 | <% end %> |
|
82 | </table> |
|
84 | </table> |
@@ -8,22 +8,22 | |||||
|
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 => 20150914 |
|
14 | + ActiveRecord::Schema.define(:version => 20150914155101) 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", :limit => 16777215 |
|
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" |
@@ -47,25 +47,25 | |||||
|
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" |
|
53 | + t.text "body", :limit => 16777215 |
|
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" |
|
65 | + t.text "description", :limit => 16777215 |
|
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" |
@@ -81,12 +81,13 | |||||
|
81 |
|
81 | ||
|
82 | create_table "heart_beats", :force => true do |t| |
|
82 | create_table "heart_beats", :force => true do |t| |
|
83 | t.integer "user_id" |
|
83 | t.integer "user_id" |
|
84 | t.string "ip_address" |
|
84 | t.string "ip_address" |
|
85 | t.datetime "created_at", :null => false |
|
85 | t.datetime "created_at", :null => false |
|
86 | t.datetime "updated_at", :null => false |
|
86 | t.datetime "updated_at", :null => false |
|
|
87 | + t.string "status" | ||
|
87 | end |
|
88 | end |
|
88 |
|
89 | ||
|
89 | create_table "languages", :force => true do |t| |
|
90 | create_table "languages", :force => true do |t| |
|
90 | t.string "name", :limit => 10 |
|
91 | t.string "name", :limit => 10 |
|
91 | t.string "pretty_name" |
|
92 | t.string "pretty_name" |
|
92 | t.string "ext", :limit => 10 |
|
93 | t.string "ext", :limit => 10 |
@@ -101,16 +102,16 | |||||
|
101 | end |
|
102 | end |
|
102 |
|
103 | ||
|
103 | create_table "messages", :force => true do |t| |
|
104 | create_table "messages", :force => true do |t| |
|
104 | t.integer "sender_id" |
|
105 | t.integer "sender_id" |
|
105 | t.integer "receiver_id" |
|
106 | t.integer "receiver_id" |
|
106 | t.integer "replying_message_id" |
|
107 | t.integer "replying_message_id" |
|
107 | - t.text "body" |
|
108 | + t.text "body", :limit => 16777215 |
|
108 | t.boolean "replied" |
|
109 | t.boolean "replied" |
|
109 | - t.datetime "created_at", :null => false |
|
110 | + t.datetime "created_at", :null => false |
|
110 | - t.datetime "updated_at", :null => false |
|
111 | + t.datetime "updated_at", :null => false |
|
111 | end |
|
112 | end |
|
112 |
|
113 | ||
|
113 | create_table "problems", :force => true do |t| |
|
114 | create_table "problems", :force => true do |t| |
|
114 | t.string "name", :limit => 30 |
|
115 | t.string "name", :limit => 30 |
|
115 | t.string "full_name" |
|
116 | t.string "full_name" |
|
116 | t.integer "full_score" |
|
117 | t.integer "full_score" |
@@ -146,13 +147,13 | |||||
|
146 | end |
|
147 | end |
|
147 |
|
148 | ||
|
148 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
149 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
149 |
|
150 | ||
|
150 | create_table "sessions", :force => true do |t| |
|
151 | create_table "sessions", :force => true do |t| |
|
151 | t.string "session_id" |
|
152 | t.string "session_id" |
|
152 | - t.text "data" |
|
153 | + t.text "data", :limit => 16777215 |
|
153 | t.datetime "updated_at" |
|
154 | t.datetime "updated_at" |
|
154 | end |
|
155 | end |
|
155 |
|
156 | ||
|
156 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
157 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
157 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
158 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
158 |
|
159 | ||
@@ -174,20 +175,20 | |||||
|
174 | end |
|
175 | end |
|
175 |
|
176 | ||
|
176 | create_table "submissions", :force => true do |t| |
|
177 | create_table "submissions", :force => true do |t| |
|
177 | t.integer "user_id" |
|
178 | t.integer "user_id" |
|
178 | t.integer "problem_id" |
|
179 | t.integer "problem_id" |
|
179 | t.integer "language_id" |
|
180 | t.integer "language_id" |
|
180 | - t.text "source" |
|
181 | + t.text "source", :limit => 16777215 |
|
181 | t.binary "binary" |
|
182 | t.binary "binary" |
|
182 | t.datetime "submitted_at" |
|
183 | t.datetime "submitted_at" |
|
183 | t.datetime "compiled_at" |
|
184 | t.datetime "compiled_at" |
|
184 | - t.text "compiler_message" |
|
185 | + t.text "compiler_message", :limit => 16777215 |
|
185 | t.datetime "graded_at" |
|
186 | t.datetime "graded_at" |
|
186 | t.integer "points" |
|
187 | t.integer "points" |
|
187 | - t.text "grader_comment" |
|
188 | + t.text "grader_comment", :limit => 16777215 |
|
188 | t.integer "number" |
|
189 | t.integer "number" |
|
189 | t.string "source_filename" |
|
190 | t.string "source_filename" |
|
190 | t.float "max_runtime" |
|
191 | t.float "max_runtime" |
|
191 | t.integer "peak_memory" |
|
192 | t.integer "peak_memory" |
|
192 | t.integer "effective_code_length" |
|
193 | t.integer "effective_code_length" |
|
193 | t.string "ip_address" |
|
194 | t.string "ip_address" |
@@ -202,33 +203,33 | |||||
|
202 | t.integer "status" |
|
203 | t.integer "status" |
|
203 | t.datetime "updated_at" |
|
204 | t.datetime "updated_at" |
|
204 | end |
|
205 | end |
|
205 |
|
206 | ||
|
206 | create_table "test_pairs", :force => true do |t| |
|
207 | create_table "test_pairs", :force => true do |t| |
|
207 | t.integer "problem_id" |
|
208 | t.integer "problem_id" |
|
208 |
- t.text "input", :limit => |
|
209 | + t.text "input", :limit => 2147483647 |
|
209 |
- t.text "solution", :limit => |
|
210 | + t.text "solution", :limit => 2147483647 |
|
210 | - t.datetime "created_at", :null => false |
|
211 | + t.datetime "created_at", :null => false |
|
211 | - t.datetime "updated_at", :null => false |
|
212 | + t.datetime "updated_at", :null => false |
|
212 | end |
|
213 | end |
|
213 |
|
214 | ||
|
214 | create_table "test_requests", :force => true do |t| |
|
215 | create_table "test_requests", :force => true do |t| |
|
215 | t.integer "user_id" |
|
216 | t.integer "user_id" |
|
216 | t.integer "problem_id" |
|
217 | t.integer "problem_id" |
|
217 | t.integer "submission_id" |
|
218 | t.integer "submission_id" |
|
218 | t.string "input_file_name" |
|
219 | t.string "input_file_name" |
|
219 | t.string "output_file_name" |
|
220 | t.string "output_file_name" |
|
220 | t.string "running_stat" |
|
221 | t.string "running_stat" |
|
221 | t.integer "status" |
|
222 | t.integer "status" |
|
222 | - t.datetime "updated_at", :null => false |
|
223 | + t.datetime "updated_at", :null => false |
|
223 | t.datetime "submitted_at" |
|
224 | t.datetime "submitted_at" |
|
224 | t.datetime "compiled_at" |
|
225 | t.datetime "compiled_at" |
|
225 | - t.text "compiler_message" |
|
226 | + t.text "compiler_message", :limit => 16777215 |
|
226 | t.datetime "graded_at" |
|
227 | t.datetime "graded_at" |
|
227 | t.string "grader_comment" |
|
228 | t.string "grader_comment" |
|
228 | - t.datetime "created_at", :null => false |
|
229 | + t.datetime "created_at", :null => false |
|
229 | t.float "running_time" |
|
230 | t.float "running_time" |
|
230 | t.string "exit_status" |
|
231 | t.string "exit_status" |
|
231 | t.integer "memory_usage" |
|
232 | t.integer "memory_usage" |
|
232 | end |
|
233 | end |
|
233 |
|
234 | ||
|
234 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
235 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
@@ -250,15 +251,15 | |||||
|
250 | t.string "email" |
|
251 | t.string "email" |
|
251 | t.integer "site_id" |
|
252 | t.integer "site_id" |
|
252 | t.integer "country_id" |
|
253 | t.integer "country_id" |
|
253 | t.boolean "activated", :default => false |
|
254 | t.boolean "activated", :default => false |
|
254 | t.datetime "created_at" |
|
255 | t.datetime "created_at" |
|
255 | t.datetime "updated_at" |
|
256 | t.datetime "updated_at" |
|
|
257 | + t.string "section" | ||
|
256 | t.boolean "enabled", :default => true |
|
258 | t.boolean "enabled", :default => true |
|
257 | t.string "remark" |
|
259 | t.string "remark" |
|
258 | t.string "last_ip" |
|
260 | t.string "last_ip" |
|
259 | - t.string "section" |
|
||
|
260 | end |
|
261 | end |
|
261 |
|
262 | ||
|
262 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
263 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
263 |
|
264 | ||
|
264 | end |
|
265 | end |
deleted file |
You need to be logged in to leave comments.
Login now