Description:
add config for heartbeat response update heartbeat view
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

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
@@ -17,14 +17,15
17 # end
17 # end
18 # hb.touch
18 # hb.touch
19 #else
19 #else
20 # HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip)
20 # HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip)
21 #end
21 #end
22 HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status])
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 end
25 end
25
26
26 def index
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 @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count
29 @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count
29 end
30 end
30 end
31 end
@@ -9,22 +9,24
9 $('#my_table').tablesorter({widgets: ['zebra']});
9 $('#my_table').tablesorter({widgets: ['zebra']});
10 });
10 });
11
11
12 %h1 Heart Beat Count
12 %h1 Heart Beat Count
13 = "Last 5 minutes distinct user count = #{@num}"
13 = "Last 5 minutes distinct user count = #{@num}"
14
14
15 - %h1 Heart Beat List
15 + %h1 Heart Beat from preview 2 hours
16
16
17 %table.tablesorter-cafe#my_table
17 %table.tablesorter-cafe#my_table
18 %thead
18 %thead
19 %tr
19 %tr
20 %th Login
20 %th Login
21 %th Full name
21 %th Full name
22 %th IP
22 %th IP
23 - %th Last Update
23 + %th Status
24 + %th Update
24 %tbody
25 %tbody
25 - @hb.each do |hb|
26 - @hb.each do |hb|
26 %tr{class: cycle('info-even','info-odd')}
27 %tr{class: cycle('info-even','info-odd')}
27 %td= link_to hb.user.login, controller: :users, :action => 'profile', :id => hb.user.id
28 %td= link_to hb.user.login, controller: :users, :action => 'profile', :id => hb.user.id
28 %td= hb.user.full_name
29 %td= hb.user.full_name
29 %td= hb.ip_address
30 %td= hb.ip_address
31 + %td= hb.status
30 %td= "#{time_ago_in_words(hb.updated_at)} ago"
32 %td= "#{time_ago_in_words(hb.updated_at)} ago"
@@ -8,13 +8,13
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 => 20150914223258) do
14 + ActiveRecord::Schema.define(:version => 20150916054105) 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
@@ -84,12 +84,14
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 t.string "status"
88 end
88 end
89
89
90 + add_index "heart_beats", ["updated_at"], :name => "index_heart_beats_on_updated_at"
91 +
90 create_table "languages", :force => true do |t|
92 create_table "languages", :force => true do |t|
91 t.string "name", :limit => 10
93 t.string "name", :limit => 10
92 t.string "pretty_name"
94 t.string "pretty_name"
93 t.string "ext", :limit => 10
95 t.string "ext", :limit => 10
94 t.string "common_ext"
96 t.string "common_ext"
95 end
97 end
You need to be logged in to leave comments. Login now