Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Normalize accounts that were closed manually #2507

Closed
wants to merge 3 commits into from

Conversation

Changaco
Copy link
Contributor

#2412 implemented account closing differently than the deactivate script that was being run manually before: we don't rename the participant by prefixing deactivated- anymore, and we clear personal information. This PR updates the DB to make it as if the deactivated accounts had been closed using the new method.

, giving = 0
, pledging = 0
, receiving = 0
WHERE username LIKE 'deactivated-%';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a need to set so many things? It seems like all you'd want is:

UPDATE participants
   SET username = substring(username from 13)
     , username_lower = lower(substring(username from 13))
     , is_closed = true
 WHERE username LIKE 'deactivated-%';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seanlinsley Yes, we want to clear personal information, like the new account closing process does.

@chadwhitacre
Copy link
Contributor

I'm comparing this SQL to what we have under Participant.close. Is there a reason we're not worrying about community or team memberships here?

In general, I'm finding it tedious to compare the behavior of this SQL with the behavior of Participant.close. Would it make more sense to do something like (untested) ...

#!/usr/bin/env python

from gittip import wireup

db = wireup.db(wireup.env())
deactivated = db.all("select participants.*::participants from participants "
                     "where username like 'deactivated-%'")

for participant in deactivated:
    participant.change_username(participant.username[len('deactivated-'):])
    participant.close(disbursement_strategy=None)

@Changaco
Copy link
Contributor Author

@whit537

Is there a reason we're not worrying about community or team memberships here?

Community memberships because I forgot, team memberships because there aren't any.

Would it make more sense to do something like (untested)

Maybe, but we'll have to deal with the problem that one of the participants has a nonzero balance, otherwise we'll get BalanceIsNotZero.

@chadwhitacre
Copy link
Contributor

Maybe, but we'll have to deal with the problem that one of the participants has a nonzero balance, otherwise we'll get BalanceIsNotZero.

That sounds like something we'll have to deal with anyway. Do they have any tips set up?

@chadwhitacre
Copy link
Contributor

@Changaco I've dealt with the balance by refunding it to the person it came from originally, which is what the person closing their account wanted. Note though that it had been given to an account that was merged with another, which I believe is how we ended up in this situation in the first place: a deactivated account with a non-zero balance.

@chadwhitacre
Copy link
Contributor

Can I bump this back to you, @Changaco?

@Changaco
Copy link
Contributor Author

@whit537 I've rewritten in python and tested on a local backup. Ready for merge.

@chadwhitacre
Copy link
Contributor

Done.

!m @Changaco

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants