注册优化
This commit is contained in:
parent
08e9b8d563
commit
7064e5b413
|
@ -139,12 +139,7 @@ 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)
|
||||
|
@ -154,13 +149,9 @@ 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
|
||||
|
|
|
@ -33,17 +33,10 @@ module AccountHelper
|
|||
end
|
||||
|
||||
def automatically_register(user, &block)
|
||||
tStarttime = Time.now
|
||||
# Automatic activation
|
||||
user.activate
|
||||
user.last_login_on = Time.now
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "register_130 wait time = #{tUsedtime} ms"
|
||||
if user.save
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "register_131 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)
|
||||
|
@ -51,9 +44,6 @@ module AccountHelper
|
|||
else
|
||||
yield if block_given?
|
||||
end
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "register_132 wait time = #{tUsedtime} ms"
|
||||
user
|
||||
end
|
||||
|
||||
|
|
|
@ -488,13 +488,9 @@ class User < Principal
|
|||
|
||||
def update_hashed_password
|
||||
# update hashed_password if password was set
|
||||
tStarttime = Time.now
|
||||
if self.password && self.auth_source_id.blank?
|
||||
salt_password(password)
|
||||
end
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "update_hashed_password wait time = #{tUsedtime} ms"
|
||||
end
|
||||
|
||||
alias :base_reload :reload
|
||||
|
@ -1190,38 +1186,32 @@ class User < Principal
|
|||
end
|
||||
end
|
||||
private
|
||||
|
||||
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.id)
|
||||
end
|
||||
|
||||
#用户动态公共表记录
|
||||
def act_as_principal_activity
|
||||
tStarttime = Time.now
|
||||
self.principal_acts << PrincipalActivity.new(:user_id => self.id,:principal_id => self.id)
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "act_as_principal_activity wait time = #{tUsedtime} ms"
|
||||
end
|
||||
|
||||
# 注册用户的时候消息默认点击时间为用户创建时间
|
||||
def add_onclick_time
|
||||
tStarttime = Time.now
|
||||
if OnclickTime.where("user_id =?" , self.id).first.nil?
|
||||
OnclickTime.create(:user_id => self.id, :onclick_time => self.created_on)
|
||||
end
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "add_onclick_time wait time = #{tUsedtime} ms"
|
||||
end
|
||||
|
||||
#为新注册用户发送留言
|
||||
def add_new_jour
|
||||
tStarttime = Time.now
|
||||
self.delay.add_new_jour_delay
|
||||
end
|
||||
|
||||
#为新注册用户发送留言
|
||||
def add_new_jour_delay
|
||||
Rails.logger.info "add_new_jour_delay!!!!!!!!!"
|
||||
if Setting.find_by_name("hidden_non_project") && Setting.find_by_name("hidden_non_project").value != "0"
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "add_new_jour_1 wait time = #{tUsedtime} ms"
|
||||
if Message.where("id=19504").any? and Message.where("id=19291").any? and Message.where("id=19292").any?
|
||||
lead_message1 = Message.find(19292)
|
||||
notes1 = lead_message1.content
|
||||
|
@ -1230,20 +1220,11 @@ class User < Principal
|
|||
lead_message3 = Message.find(19504)
|
||||
notes3 = lead_message3.content
|
||||
#user_id 默认为课程使者创建
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "add_new_jour_2 wait time = #{tUsedtime} ms"
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes1, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes2, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes3, :reply_id => 0, :status => true, :is_readed => false, :private => 0)
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "add_new_jour_3 wait time = #{tUsedtime} ms"
|
||||
end
|
||||
end
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "add_new_jour_4 wait time = #{tUsedtime} ms"
|
||||
end
|
||||
|
||||
# 更新邮箱的同事,更新invite_lists表中的邮箱信息
|
||||
|
@ -1307,22 +1288,14 @@ class User < Principal
|
|||
|
||||
|
||||
def create_user_ealasticsearch_index
|
||||
tStarttime = Time.now
|
||||
if self.id != 2 && self.id != 4
|
||||
self.__elasticsearch__.index_document if Rails.env.production?
|
||||
end
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "create_user_ealasticsearch_index wait time = #{tUsedtime} ms"
|
||||
end
|
||||
def update_user_ealasticsearch_index
|
||||
tStarttime = Time.now
|
||||
if self.id != 2 && self.id != 4
|
||||
self.__elasticsearch__.update_document if Rails.env.production?
|
||||
end
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
Rails.logger.info "update_elastic wait time = #{tUsedtime} ms"
|
||||
end
|
||||
def delete_user_ealasticsearch_index
|
||||
if self.id != 2 && self.id != 4
|
||||
|
|
|
@ -11,8 +11,6 @@ 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
|
||||
|
@ -21,8 +19,6 @@ 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
|
||||
|
@ -30,8 +26,6 @@ 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)
|
||||
|
@ -40,15 +34,11 @@ 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
|
||||
|
|
Loading…
Reference in New Issue