launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23441
[Merge] lp:~cjwatson/launchpad/close-account-bugsummary into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/close-account-bugsummary into lp:launchpad.
Commit message:
Skip BugSummary.viewed_by in close-account, since it's only updated when the journal is rolled up.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/close-account-bugsummary/+merge/364916
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/close-account-bugsummary into lp:launchpad.
=== modified file 'lib/lp/registry/scripts/closeaccount.py'
--- lib/lp/registry/scripts/closeaccount.py 2019-03-12 11:45:41 +0000
+++ lib/lp/registry/scripts/closeaccount.py 2019-03-21 17:41:21 +0000
@@ -148,6 +148,10 @@
('usertouseremail', 'recipient'),
('usertouseremail', 'sender'),
('xref', 'creator'),
+
+ # This is maintained by trigger functions and a garbo job. It
+ # doesn't need to be updated immediately.
+ ('bugsummary', 'viewed_by'),
}
reference_names = {
(src_tab, src_col) for src_tab, src_col, _, _, _, _ in references}
=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
--- lib/lp/registry/scripts/tests/test_closeaccount.py 2019-03-11 14:51:16 +0000
+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2019-03-21 17:41:21 +0000
@@ -10,6 +10,8 @@
import six
from storm.store import Store
from testtools.matchers import (
+ MatchesSetwise,
+ MatchesStructure,
Not,
StartsWith,
)
@@ -18,7 +20,9 @@
from zope.security.proxy import removeSecurityProxy
from lp.answers.enums import QuestionStatus
+from lp.app.enums import InformationType
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+from lp.bugs.model.bugsummary import BugSummary
from lp.hardwaredb.interfaces.hwdb import (
HWBus,
IHWDeviceSet,
@@ -407,3 +411,40 @@
other_submission, hw_submission_set.getBySubmissionKey(other_key))
self.assertEqual(
[other_submission_device], list(other_submission.devices))
+
+ def test_skips_bug_summary(self):
+ person = self.factory.makePerson()
+ other_person = self.factory.makePerson()
+ bug = self.factory.makeBug(information_type=InformationType.USERDATA)
+ bug.subscribe(person, bug.owner)
+ bug.subscribe(other_person, bug.owner)
+ store = Store.of(bug)
+ summaries = list(store.find(
+ BugSummary,
+ BugSummary.viewed_by_id.is_in([person.id, other_person.id])))
+ self.assertThat(summaries, MatchesSetwise(
+ MatchesStructure.byEquality(count=1, viewed_by=person),
+ MatchesStructure.byEquality(count=1, viewed_by=other_person)))
+ person_id = person.id
+ account_id = person.account.id
+ script = self.makeScript([six.ensure_str(person.name)])
+ with dbuser('launchpad'):
+ self.runScript(script)
+ self.assertRemoved(account_id, person_id)
+ # BugSummaryJournal has been updated, but BugSummary hasn't yet.
+ summaries = list(store.find(
+ BugSummary,
+ BugSummary.viewed_by_id.is_in([person.id, other_person.id])))
+ self.assertThat(summaries, MatchesSetwise(
+ MatchesStructure.byEquality(count=1, viewed_by=person),
+ MatchesStructure.byEquality(count=1, viewed_by=other_person),
+ MatchesStructure.byEquality(count=-1, viewed_by=person)))
+ # If we force an update (the equivalent of the
+ # BugSummaryJournalRollup garbo job), that's enough to get rid of
+ # the reference.
+ store.execute('SELECT bugsummary_rollup_journal()')
+ summaries = list(store.find(
+ BugSummary,
+ BugSummary.viewed_by_id.is_in([person.id, other_person.id])))
+ self.assertThat(summaries, MatchesSetwise(
+ MatchesStructure.byEquality(viewed_by=other_person)))
Follow ups