-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix and test for delete user #1713
Conversation
Why rename models/consistency_test.go → models/consistency.go ? |
@sapk So that it can be used in |
models/user.go
Outdated
@@ -945,13 +945,23 @@ func deleteUser(e *xorm.Session, u *User) error { | |||
// ***** END: Star ***** | |||
|
|||
// ***** START: Follow ***** | |||
followees := make([]*Follow, 0, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be changed to []int64 array and select only FollowID values into this array. I don't know what is the limitation of count for In(field, array)
but it could be optimized to update it in batches so that there would be less requests to database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lafriks I have an updated version, but it's blocked on a fix to xorm (go-xorm/builder#4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethantkoenig fix seems to be merged in xorm, you can now fetch dependency and it should be ok now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed
models/user.go
Outdated
return fmt.Errorf("decrease user follower number[%d]: %v", followees[i].FollowID, err) | ||
} | ||
} | ||
|
||
followers := make([]*Follow, 0, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as with followees
LGTM |
LGTM |
Fix bug where
num_following
fields were not correctly updated on user delete.Also add an integration test for deleting users.