diff options
author | Joe Chen <jc@unknwon.io> | 2022-11-25 23:01:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-25 23:01:41 +0800 |
commit | a7dbc970dfaac9f04addf05da97bb0aa29083e37 (patch) | |
tree | 6cc1a8b479c7be9e42a4d9fadaf8505f68455e85 /internal/db/user.go | |
parent | 644a3a9d78a691af8f0f5ab04d5d44207b5d03dc (diff) |
fix(db): update `user.updated_unix` upon changing username (#7262)
Diffstat (limited to 'internal/db/user.go')
-rw-r--r-- | internal/db/user.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/internal/db/user.go b/internal/db/user.go index 5d75bfca..24af0ec1 100644 --- a/internal/db/user.go +++ b/internal/db/user.go @@ -31,14 +31,6 @@ func (u *User) BeforeInsert() { u.UpdatedUnix = u.CreatedUnix } -// TODO(unknwon): Refactoring together with methods that do updates. -func (u *User) BeforeUpdate() { - if u.MaxRepoCreation < -1 { - u.MaxRepoCreation = -1 - } - u.UpdatedUnix = time.Now().Unix() -} - // TODO(unknwon): Delete me once refactoring is done. func (u *User) AfterSet(colName string, _ xorm.Cell) { switch colName { @@ -49,13 +41,6 @@ func (u *User) AfterSet(colName string, _ xorm.Cell) { } } -// Deprecated: Use OrgsUsers.CountByUser instead. -// -// TODO(unknwon): Delete me once no more call sites in this file. -func (u *User) getOrganizationCount(e Engine) (int64, error) { - return e.Where("uid=?", u.ID).Count(new(OrgUser)) -} - func updateUser(e Engine, u *User) error { // Organization does not need email if !u.IsOrganization() { @@ -82,6 +67,14 @@ func updateUser(e Engine, u *User) error { return err } +// TODO(unknwon): Refactoring together with methods that do updates. +func (u *User) BeforeUpdate() { + if u.MaxRepoCreation < -1 { + u.MaxRepoCreation = -1 + } + u.UpdatedUnix = time.Now().Unix() +} + // UpdateUser updates user's information. func UpdateUser(u *User) error { return updateUser(x, u) @@ -202,6 +195,13 @@ func deleteUser(e *xorm.Session, u *User) error { return nil } +// Deprecated: Use OrgsUsers.CountByUser instead. +// +// TODO(unknwon): Delete me once no more call sites in this file. +func (u *User) getOrganizationCount(e Engine) (int64, error) { + return e.Where("uid=?", u.ID).Count(new(OrgUser)) +} + // DeleteUser completely and permanently deletes everything of a user, // but issues/comments/pulls will be kept and shown as someone has been deleted. func DeleteUser(u *User) (err error) { |