Show More
Commit Description:
more heart beat feature...
Commit Description:
more heart beat feature
add reset last login ip
References:
File last commit:
Show/Diff file:
Action:
app/controllers/heartbeat_controller.rb
| 29 lines
| 743 B
| text/x-ruby
| RubyLexer
|
r533 | class HeartbeatController < ApplicationController | |||
r534 | before_filter :admin_authorization, :only => ['index'] | |||
r533 | def edit | |||
@user = User.find_by_login(params[:id]) | ||||
r534 | unless @user | |||
render text: "LOGIN_NOT_FOUND" | ||||
return | ||||
end | ||||
r533 | hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first | |||
r534 | puts "status = #{params[:status]}" | |||
r533 | if hb | |||
r534 | if params[:status] | |||
hb.status = params[:status] | ||||
hb.save | ||||
end | ||||
r533 | hb.touch | |||
else | ||||
r534 | HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) | |||
r533 | end | |||
r534 | 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 | ||||
r533 | end | |||
end | ||||