-
Notifications
You must be signed in to change notification settings - Fork 824
Management command for inactive user purge #6803
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
base: main
Are you sure you want to change the base?
Conversation
akatsoulas
left a comment
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.
How is this management command different from cleanup_expired_users? Is this going to be a one off deletion or are we going to reuse it?
| try: | ||
| user_count = deleted_objects.get("auth.User", 0) | ||
| return user_count, 0 | ||
| except (DatabaseError, IntegrityError) as e: |
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.
Why are we using these 2 exceptions here?
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.
These should be covering the actual .delete() vs. the retrieval of the user count. I'll move the deletion activity into the try. Good catch - thanks!
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.
My point was mostly about why these two specific exceptions. Why not for example OperationalError (which we have in all environments). Shall we just use Exception here?
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.
They seemed more specific to what could go wrong, but maybe being more general makes sense. I'll alter to use Exception.
Thanks!
|
This was initially dealing with Migration to bulk delete inactive users regardless of content which we decided to then approach as a management command which then got reverted due to a polluted commit.
|
akatsoulas
left a comment
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.
r+wc please hold on merging until the PR to adjust contributor metrics calculation is live
| def _bulk_delete_batch(self, User, user_ids): | ||
| try: | ||
| _, deleted_objects = User.objects.filter(id__in=user_ids).delete() | ||
| user_count = deleted_objects.get("auth.User", 0) |
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.
this line and the next should be better in the else clause of a try/except/else
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.
You are correct! Thanks!
| try: | ||
| user_count = deleted_objects.get("auth.User", 0) | ||
| return user_count, 0 | ||
| except (DatabaseError, IntegrityError) as e: |
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.
My point was mostly about why these two specific exceptions. Why not for example OperationalError (which we have in all environments). Shall we just use Exception here?
No description provided.