Show More
Commit Description:
keep all heartbeat instead of only the latest one...
Commit Description:
keep all heartbeat instead of only the latest one
(grafted from 0bdf62fde5fdb94d6f94c2b8b8ebc58ffbe8d2f9)
References:
File last commit:
Show/Diff file:
Action:
app/controllers/heartbeat_controller.rb
| 30 lines
| 850 B
| text/x-ruby
| RubyLexer
|
r540 | class HeartbeatController < ApplicationController | |||
r541 | before_filter :admin_authorization, :only => ['index'] | |||
r540 | def edit | |||
@user = User.find_by_login(params[:id]) | ||||
r541 | unless @user | |||
render text: "LOGIN_NOT_FOUND" | ||||
return | ||||
end | ||||
r544 | #hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first | |||
#puts "status = #{params[:status]}" | ||||
#if hb | ||||
# if params[:status] | ||||
# hb.status = params[:status] | ||||
# hb.save | ||||
# end | ||||
# hb.touch | ||||
#else | ||||
# HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) | ||||
#end | ||||
HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) | ||||
r541 | render text: "OK" | |||
end | ||||
def index | ||||
@hb = HeartBeat.includes(:user).order(:user_id).all | ||||
@num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count | ||||
r540 | end | |||
end | ||||