Merge lp:~cjwatson/launchpad/remove-person-settings-enf-populator into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17992
Proposed branch: lp:~cjwatson/launchpad/remove-person-settings-enf-populator
Merge into: lp:launchpad
Diff against target: 141 lines (+3/-81)
2 files modified
lib/lp/scripts/garbo.py (+1/-28)
lib/lp/scripts/tests/test_garbo.py (+2/-53)
To merge this branch: bzr merge lp:~cjwatson/launchpad/remove-person-settings-enf-populator
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+291006@code.launchpad.net

Commit message

Remove completed PersonSettings.expanded_notification_footers population job.

Description of the change

Remove completed PersonSettings.expanded_notification_footers population job. It completed on all instances ages ago.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/scripts/garbo.py'
2--- lib/lp/scripts/garbo.py 2016-03-02 14:03:42 +0000
3+++ lib/lp/scripts/garbo.py 2016-04-05 15:55:09 +0000
4@@ -70,10 +70,7 @@
5 )
6 from lp.hardwaredb.model.hwdb import HWSubmission
7 from lp.registry.model.commercialsubscription import CommercialSubscription
8-from lp.registry.model.person import (
9- Person,
10- PersonSettings,
11- )
12+from lp.registry.model.person import Person
13 from lp.registry.model.product import Product
14 from lp.registry.model.teammembership import TeamMembership
15 from lp.services.config import config
16@@ -1438,29 +1435,6 @@
17 """
18
19
20-class PersonSettingsENFPopulator(BulkPruner):
21- """Populates PersonSettings.expanded_notification_footers."""
22-
23- target_table_class = PersonSettings
24- ids_to_prune_query = """
25- SELECT person
26- FROM PersonSettings
27- WHERE expanded_notification_footers IS NULL
28- """
29-
30- def __call__(self, chunk_size):
31- """See `ITunableLoop`."""
32- result = self.store.execute("""
33- UPDATE PersonSettings
34- SET expanded_notification_footers = FALSE
35- WHERE person IN (
36- SELECT * FROM
37- cursor_fetch('%s', %d) AS f(person integer))
38- """ % (self.cursor_name, chunk_size))
39- self._num_removed = result.rowcount
40- transaction.commit()
41-
42-
43 class BaseDatabaseGarbageCollector(LaunchpadCronScript):
44 """Abstract base class to run a collection of TunableLoops."""
45 script_name = None # Script name for locking and database user. Override.
46@@ -1745,7 +1719,6 @@
47 LoginTokenPruner,
48 ObsoleteBugAttachmentPruner,
49 OldTimeLimitedTokenDeleter,
50- PersonSettingsENFPopulator,
51 POTranslationPruner,
52 PreviewDiffPruner,
53 ProductVCSPopulator,
54
55=== modified file 'lib/lp/scripts/tests/test_garbo.py'
56--- lib/lp/scripts/tests/test_garbo.py 2016-03-02 14:03:42 +0000
57+++ lib/lp/scripts/tests/test_garbo.py 2016-04-05 15:55:09 +0000
58@@ -16,10 +16,7 @@
59 import time
60
61 from pytz import UTC
62-from storm.exceptions import (
63- LostObjectError,
64- NoneError,
65- )
66+from storm.exceptions import LostObjectError
67 from storm.expr import (
68 In,
69 Like,
70@@ -73,9 +70,7 @@
71 from lp.registry.interfaces.accesspolicy import IAccessPolicySource
72 from lp.registry.interfaces.person import IPersonSet
73 from lp.registry.interfaces.teammembership import TeamMembershipStatus
74-from lp.registry.model.codeofconduct import SignedCodeOfConduct
75 from lp.registry.model.commercialsubscription import CommercialSubscription
76-from lp.registry.model.person import PersonSettings
77 from lp.registry.model.teammembership import TeamMembership
78 from lp.scripts.garbo import (
79 AntiqueSessionPruner,
80@@ -129,10 +124,7 @@
81 TestCase,
82 TestCaseWithFactory,
83 )
84-from lp.testing.dbuser import (
85- dbuser,
86- switch_dbuser,
87- )
88+from lp.testing.dbuser import switch_dbuser
89 from lp.testing.layers import (
90 DatabaseLayer,
91 LaunchpadScriptLayer,
92@@ -1394,49 +1386,6 @@
93 self._test_LiveFSFilePruner(
94 'application/octet-stream', 0, expected_count=1)
95
96- def test_PersonSettingsENFPopulator(self):
97- switch_dbuser('testadmin')
98- store = IMasterStore(PersonSettings)
99- people_enf_none = []
100- people_enf_false = []
101- people_enf_true = []
102- for _ in range(2):
103- person = self.factory.makePerson()
104- try:
105- person.expanded_notification_footers = None
106- except NoneError:
107- # Now enforced by DB NOT NULL constraint; backfilling is no
108- # longer necessary.
109- return
110- people_enf_none.append(person)
111- person = self.factory.makePerson()
112- person.expanded_notification_footers = False
113- people_enf_false.append(person)
114- person = self.factory.makePerson()
115- person.expanded_notification_footers = True
116- people_enf_true.append(person)
117- settings_count = store.find(PersonSettings).count()
118- self.runDaily()
119- switch_dbuser('testadmin')
120-
121- # No rows have been deleted.
122- self.assertEqual(settings_count, store.find(PersonSettings).count())
123-
124- def _assert_enf_by_person(person, expected):
125- record = store.find(
126- PersonSettings, PersonSettings.person == person.id).one()
127- self.assertEqual(expected, record.expanded_notification_footers)
128-
129- # Rows with expanded_notification_footers=None have been backfilled.
130- for person in people_enf_none:
131- _assert_enf_by_person(person, False)
132-
133- # Other rows have been left alone.
134- for person in people_enf_false:
135- _assert_enf_by_person(person, False)
136- for person in people_enf_true:
137- _assert_enf_by_person(person, True)
138-
139
140 class TestGarboTasks(TestCaseWithFactory):
141 layer = LaunchpadZopelessLayer