Fix stale user highest role stats on dormant user deactivation
What does this MR do and why?
This MR fixes #369393 (closed) by updating the dormant user deactivation worker to execute user deactivations via the User model instead of running a SQL query.
A post-deployment migration is included to remove any User Highest Role entries that belong to deactivated users. After execution of the migration, the Users Statistics
page may still show inaccurate data until the CreateStatisticsWorker
job runs.
Migrations
This MR includes the following migration:
RemoveDeactivatedUserHighestRoleStats
- removes entries in the user_highest_roles
that belong to deactivated users. This data is normally deleted when a user is deactivated, but they were not being deleted when users were deactivated via the dormant user deactivation feature.
There is no revert action in this migration.
UP
main: == 20220802204737 RemoveDeactivatedUserHighestRoleStats: migrating ============
main: == 20220802204737 RemoveDeactivatedUserHighestRoleStats: migrated (0.0411s) ===
DOWN
main: == 20220802204737 RemoveDeactivatedUserHighestRoleStats: reverting ============
main: == 20220802204737 RemoveDeactivatedUserHighestRoleStats: reverted (0.0014s) ===
Screenshots or screen recordings
See #369393 (closed)
The counts in the Users Statistics
screenshot are corrected by this MR to reflect only active users. There are no UI changes.
How to set up and validate locally
See steps to reproduce in #369393 (closed)
In Deactivate users via the dormant user deactivation feature step 8, this MR will change the outcome by updating the Users Statistics
page counts.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.