From 7d81a5230871201b21158249c690f2634e44022b Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 3 Nov 2016 10:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=97=B6=E5=80=99=E5=8A=A0?= =?UTF-8?q?=E7=82=B9=E6=97=A5=E5=BF=97=E8=B0=83=E8=AF=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 9 +++++++++ app/helpers/account_helper.rb | 7 +++++++ app/services/users_service.rb | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 02dfe9a45..fcc4c58d6 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -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 diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb index 827557a40..00b12d6f7 100644 --- a/app/helpers/account_helper.rb +++ b/app/helpers/account_helper.rb @@ -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 diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 540e1bbff..95e56d325 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -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