Skip to content
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

WIP: Clean user records #482

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

marcelkornblum
Copy link
Contributor

made a management command that will:

  • delete all user records with no associated profile
  • delete all profiles with no associated user

made another management command that will:

  • mark users as inactive where their profile is marked as inactive
  • mark profiles as inactive where the user is marked as inactive
  • mark users/profiles as inactive when their last login is over 90 days ago (configurable), and they have an inactive profile on SSO (NB dependent on a PR on staff-sso) (NB is API intensive and so can be batched)

Amended the active/inactive setters in the codebase (inc admin) to make sure they stay in sync

@@ -783,6 +783,10 @@ def save(self, *args, **kwargs):
from peoplefinder.services.person import PersonService

self.profile_completion = PersonService().get_profile_completion(person=self)

if self.user and self.is_active != self.user.is_active:
self.user.is_active = self.is_active
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the profile is set to active and the user is set to inactive, it will update the user to be active, is this the desired behaviour?

Is there any way that updates the User is active flag? (maybe from SSO?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this as provocation - my assumption is whichever record (User / Person) is being saved, you probably want the other record's is_active to match.... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sso connection is waiting on a erlated PR but is there in the management command; I could abstract this to a service

@marcelkornblum marcelkornblum marked this pull request as draft October 20, 2023 09:02
@marcelkornblum marcelkornblum changed the title Clean user records WIP: Clean user records Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants