mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Update User#last_login_on only once per minute and user to reduce DB lock contention on users table (#28952).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@17403 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
400b91f9c7
commit
438d2f65fd
@ -239,7 +239,7 @@ class User < Principal
|
||||
end
|
||||
end
|
||||
end
|
||||
user.update_column(:last_login_on, Time.now) if user && !user.new_record? && user.active?
|
||||
user.update_last_login_on! if user && !user.new_record? && user.active?
|
||||
user
|
||||
rescue => text
|
||||
raise text
|
||||
@ -249,7 +249,7 @@ class User < Principal
|
||||
def self.try_to_autologin(key)
|
||||
user = Token.find_active_user('autologin', key, Setting.autologin.to_i)
|
||||
if user
|
||||
user.update_column(:last_login_on, Time.now)
|
||||
user.update_last_login_on!
|
||||
user
|
||||
end
|
||||
end
|
||||
@ -315,6 +315,12 @@ class User < Principal
|
||||
update_attribute(:status, STATUS_LOCKED)
|
||||
end
|
||||
|
||||
def update_last_login_on!
|
||||
return if last_login_on.present? && last_login_on >= 1.minute.ago
|
||||
|
||||
update_column(:last_login_on, Time.now)
|
||||
end
|
||||
|
||||
# Returns true if +clear_password+ is the correct user's password, otherwise false
|
||||
def check_password?(clear_password)
|
||||
if auth_source_id.present?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user