Description:
add config for heartbeat response
update heartbeat view
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r538:4c7c815d4901 - - 4 files changed: 20 inserted, 5 deleted
@@ -0,0 +1,10 | |||
|
1 | + class UpdateHeartBeat < ActiveRecord::Migration | |
|
2 | + def up | |
|
3 | + GraderConfiguration.create key: 'right.heartbeat_response', value_type: 'string', value:'OK', description:'Heart beat response text' | |
|
4 | + add_index :heart_beats, :updated_at | |
|
5 | + end | |
|
6 | + | |
|
7 | + def down | |
|
8 | + remove_index :heart_beats, :updated_at | |
|
9 | + end | |
|
10 | + end |
@@ -20,11 +20,12 | |||
|
20 | 20 | # HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) |
|
21 | 21 | #end |
|
22 | 22 | HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) |
|
23 | - render text: "OK" | |
|
23 | + | |
|
24 | + render text: (GraderConfiguration['right.heartbeat_response'] || 'OK') | |
|
24 | 25 | end |
|
25 | 26 | |
|
26 | 27 | def index |
|
27 | - @hb = HeartBeat.includes(:user).order(:user_id).all | |
|
28 | + @hb = HeartBeat.where("updated_at >= ?",Time.zone.now-2.hours).includes(:user).order(:user_id).all | |
|
28 | 29 | @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count |
|
29 | 30 | end |
|
30 | 31 | end |
@@ -12,7 +12,7 | |||
|
12 | 12 | %h1 Heart Beat Count |
|
13 | 13 | = "Last 5 minutes distinct user count = #{@num}" |
|
14 | 14 | |
|
15 |
- %h1 Heart Beat |
|
|
15 | + %h1 Heart Beat from preview 2 hours | |
|
16 | 16 | |
|
17 | 17 | %table.tablesorter-cafe#my_table |
|
18 | 18 | %thead |
@@ -20,11 +20,13 | |||
|
20 | 20 | %th Login |
|
21 | 21 | %th Full name |
|
22 | 22 | %th IP |
|
23 |
- %th |
|
|
23 | + %th Status | |
|
24 | + %th Update | |
|
24 | 25 | %tbody |
|
25 | 26 | - @hb.each do |hb| |
|
26 | 27 | %tr{class: cycle('info-even','info-odd')} |
|
27 | 28 | %td= link_to hb.user.login, controller: :users, :action => 'profile', :id => hb.user.id |
|
28 | 29 | %td= hb.user.full_name |
|
29 | 30 | %td= hb.ip_address |
|
31 | + %td= hb.status | |
|
30 | 32 | %td= "#{time_ago_in_words(hb.updated_at)} ago" |
@@ -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 => 2015091 |
|
|
14 | + ActiveRecord::Schema.define(:version => 20150916054105) do | |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", :force => true do |t| |
|
17 | 17 | t.string "author" |
@@ -87,6 +87,8 | |||
|
87 | 87 | t.string "status" |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | + add_index "heart_beats", ["updated_at"], :name => "index_heart_beats_on_updated_at" | |
|
91 | + | |
|
90 | 92 | create_table "languages", :force => true do |t| |
|
91 | 93 | t.string "name", :limit => 10 |
|
92 | 94 | t.string "pretty_name" |
You need to be logged in to leave comments.
Login now