Merge lp:~cjwatson/launchpad/close-account-message-owner into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18831
Proposed branch: lp:~cjwatson/launchpad/close-account-message-owner
Merge into: lp:launchpad
Diff against target: 31 lines (+3/-0)
2 files modified
lib/lp/registry/scripts/closeaccount.py (+1/-0)
lib/lp/registry/scripts/tests/test_closeaccount.py (+2/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/close-account-message-owner
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Launchpad code reviewers Pending
Review via email: mp+360056@code.launchpad.net

Commit message

Skip Message.owner references in close-account.

Description of the change

These are created if (e.g.) the user had commented on a question at some point. There's no need to break those links.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

13:37 < nessita> cjwatson, question about your branch: the commit says "skip owner references..." but the code adds them, so I'm not sure I understand what is going on
13:39 < cjwatson> nessita: It adds them to a set called "skip" :)
13:41 < cjwatson>| close-account's job is to do as full an erasure of an account as is possible (to satisfy legal demands etc.) while not breaking referential integrity. There are way too many FKs on Person.id to be realistic to decide what to do about all of them up-front, so the purpose of the "skip" set is to be a list of FKs that we've determined are OK to keep around even after an account has been wiped ...
13:41 < cjwatson>| ... and replaced with a minimal placeholder.
13:43 < nessita> cjwatson, I understand, thanks. And the tests, do they have a machinery where by adding an owner there are asserts that will ensure is not there?
13:45 < cjwatson> nessita: Indeed. With only the test changes, one gets https://paste.ubuntu.com/p/DcKHgpfRPn/
13:45 < cjwatson>| I recently refactored close-account to be super-paranoid about what happens if any unhandled FKs are left over
13:46 < cjwatson>| So we are forced to make some kind of decision about them
13:46 < nessita> cjwatson, great, it makes sense and I think it looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/scripts/closeaccount.py'
2--- lib/lp/registry/scripts/closeaccount.py 2018-12-03 11:34:32 +0000
3+++ lib/lp/registry/scripts/closeaccount.py 2018-12-04 13:15:36 +0000
4@@ -100,6 +100,7 @@
5 ('gitrule', 'creator'),
6 ('gitrulegrant', 'grantor'),
7 ('gitsubscription', 'subscribed_by'),
8+ ('message', 'owner'),
9 ('messageapproval', 'disposed_by'),
10 ('messageapproval', 'posted_by'),
11 ('packagecopyrequest', 'requester'),
12
13=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
14--- lib/lp/registry/scripts/tests/test_closeaccount.py 2018-11-29 18:44:25 +0000
15+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2018-12-04 13:15:36 +0000
16@@ -206,6 +206,7 @@
17 QuestionStatus.OPEN, QuestionStatus.NEEDSINFO,
18 QuestionStatus.ANSWERED):
19 question = self.factory.makeQuestion(owner=person)
20+ question.addComment(person, "comment")
21 removeSecurityProxy(question).status = status
22 questions.append(question)
23 script = self.makeScript([nativeString(person.name)])
24@@ -227,6 +228,7 @@
25 QuestionStatus.SOLVED, QuestionStatus.EXPIRED,
26 QuestionStatus.INVALID):
27 question = self.factory.makeQuestion(owner=person)
28+ question.addComment(person, "comment")
29 removeSecurityProxy(question).status = status
30 questions[status] = question
31 script = self.makeScript([nativeString(person.name)])