注册时候加点日志调试用

This commit is contained in:
yuanke 2016-11-03 10:16:34 +08:00
parent 22f4fbf089
commit 7d81a52308
3 changed files with 26 additions and 0 deletions

View File

@ -139,7 +139,12 @@ class AccountController < ApplicationController
end
else
us = UsersService.new
tStarttime = Time.now
@user = us.register user_params.merge(:should_confirmation_password => true)
tEndtime = Time.now
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
logger.info "register_1 wait time = #{tUsedtime} ms"
case Setting.self_registration
when '1'
#register_by_email_activation(@user)
@ -149,9 +154,13 @@ class AccountController < ApplicationController
end
when '3'
#register_automatically(@user)
tStarttime = Time.now
if !@user.new_record?
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
tEndtime = Time.now
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
logger.info "register_2 wait time = #{tUsedtime} ms"
redirect_to my_account_url(:tip=>1)
else
redirect_to signin_path

View File

@ -33,10 +33,14 @@ module AccountHelper
end
def automatically_register(user, &block)
tStarttime = Time.now
# Automatic activation
user.activate
user.last_login_on = Time.now
if user.save
tEndtime = Time.now
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
logger.info "register_130 wait time = #{tUsedtime} ms"
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
#self.logged_user = user
#flash[:notice] = l(:notice_account_activated)
@ -44,6 +48,9 @@ module AccountHelper
else
yield if block_given?
end
tEndtime = Time.now
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
logger.info "register_131 wait time = #{tUsedtime} ms"
user
end

View File

@ -11,6 +11,8 @@ class UsersService
#成功返回注册后的User实例失败直接抛异常
def register(params)
Rails.logger.info "register_11"
Rails.logger.info Time.now.to_i*1000+Time.now.usec/1000
@user = User.new
@user.admin = false
@user.register
@ -19,6 +21,8 @@ class UsersService
password = params[:password]
password_confirmation = params[:password_confirmation]
should_confirmation_password = params[:should_confirmation_password]
Rails.logger.info "register_12"
Rails.logger.info Time.now.to_i*1000+Time.now.usec/1000
if !password.blank? && !password_confirmation.blank? && should_confirmation_password
@user.password, @user.password_confirmation = password, password_confirmation
elsif !password.blank? && !should_confirmation_password
@ -26,6 +30,8 @@ class UsersService
else
@user.password = ""
end
Rails.logger.info "register_13"
Rails.logger.info Time.now.to_i*1000+Time.now.usec/1000
case Setting.self_registration
when '1'
@user = email_activation_register(@user)
@ -34,11 +40,15 @@ class UsersService
else
@user = administrator_manually__register(@user)
end
Rails.logger.info "register_14"
Rails.logger.info Time.now.to_i*1000+Time.now.usec/1000
if @user.id != nil
ue = @user.user_extensions ||= UserExtensions.new
ue.user_id = @user.id
ue.save
end
Rails.logger.info "register_15"
Rails.logger.info Time.now.to_i*1000+Time.now.usec/1000
@user
#img_url = url_to_avatar(@user)
#gender = @user.user_extensions.gender.nil? ? 0 : @user.user_extensions.gender