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
=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py 2016-03-02 14:03:42 +0000
+++ lib/lp/scripts/garbo.py 2016-04-05 15:55:09 +0000
@@ -70,10 +70,7 @@
70 )70 )
71from lp.hardwaredb.model.hwdb import HWSubmission71from lp.hardwaredb.model.hwdb import HWSubmission
72from lp.registry.model.commercialsubscription import CommercialSubscription72from lp.registry.model.commercialsubscription import CommercialSubscription
73from lp.registry.model.person import (73from lp.registry.model.person import Person
74 Person,
75 PersonSettings,
76 )
77from lp.registry.model.product import Product74from lp.registry.model.product import Product
78from lp.registry.model.teammembership import TeamMembership75from lp.registry.model.teammembership import TeamMembership
79from lp.services.config import config76from lp.services.config import config
@@ -1438,29 +1435,6 @@
1438 """1435 """
14391436
14401437
1441class PersonSettingsENFPopulator(BulkPruner):
1442 """Populates PersonSettings.expanded_notification_footers."""
1443
1444 target_table_class = PersonSettings
1445 ids_to_prune_query = """
1446 SELECT person
1447 FROM PersonSettings
1448 WHERE expanded_notification_footers IS NULL
1449 """
1450
1451 def __call__(self, chunk_size):
1452 """See `ITunableLoop`."""
1453 result = self.store.execute("""
1454 UPDATE PersonSettings
1455 SET expanded_notification_footers = FALSE
1456 WHERE person IN (
1457 SELECT * FROM
1458 cursor_fetch('%s', %d) AS f(person integer))
1459 """ % (self.cursor_name, chunk_size))
1460 self._num_removed = result.rowcount
1461 transaction.commit()
1462
1463
1464class BaseDatabaseGarbageCollector(LaunchpadCronScript):1438class BaseDatabaseGarbageCollector(LaunchpadCronScript):
1465 """Abstract base class to run a collection of TunableLoops."""1439 """Abstract base class to run a collection of TunableLoops."""
1466 script_name = None # Script name for locking and database user. Override.1440 script_name = None # Script name for locking and database user. Override.
@@ -1745,7 +1719,6 @@
1745 LoginTokenPruner,1719 LoginTokenPruner,
1746 ObsoleteBugAttachmentPruner,1720 ObsoleteBugAttachmentPruner,
1747 OldTimeLimitedTokenDeleter,1721 OldTimeLimitedTokenDeleter,
1748 PersonSettingsENFPopulator,
1749 POTranslationPruner,1722 POTranslationPruner,
1750 PreviewDiffPruner,1723 PreviewDiffPruner,
1751 ProductVCSPopulator,1724 ProductVCSPopulator,
17521725
=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py 2016-03-02 14:03:42 +0000
+++ lib/lp/scripts/tests/test_garbo.py 2016-04-05 15:55:09 +0000
@@ -16,10 +16,7 @@
16import time16import time
1717
18from pytz import UTC18from pytz import UTC
19from storm.exceptions import (19from storm.exceptions import LostObjectError
20 LostObjectError,
21 NoneError,
22 )
23from storm.expr import (20from storm.expr import (
24 In,21 In,
25 Like,22 Like,
@@ -73,9 +70,7 @@
73from lp.registry.interfaces.accesspolicy import IAccessPolicySource70from lp.registry.interfaces.accesspolicy import IAccessPolicySource
74from lp.registry.interfaces.person import IPersonSet71from lp.registry.interfaces.person import IPersonSet
75from lp.registry.interfaces.teammembership import TeamMembershipStatus72from lp.registry.interfaces.teammembership import TeamMembershipStatus
76from lp.registry.model.codeofconduct import SignedCodeOfConduct
77from lp.registry.model.commercialsubscription import CommercialSubscription73from lp.registry.model.commercialsubscription import CommercialSubscription
78from lp.registry.model.person import PersonSettings
79from lp.registry.model.teammembership import TeamMembership74from lp.registry.model.teammembership import TeamMembership
80from lp.scripts.garbo import (75from lp.scripts.garbo import (
81 AntiqueSessionPruner,76 AntiqueSessionPruner,
@@ -129,10 +124,7 @@
129 TestCase,124 TestCase,
130 TestCaseWithFactory,125 TestCaseWithFactory,
131 )126 )
132from lp.testing.dbuser import (127from lp.testing.dbuser import switch_dbuser
133 dbuser,
134 switch_dbuser,
135 )
136from lp.testing.layers import (128from lp.testing.layers import (
137 DatabaseLayer,129 DatabaseLayer,
138 LaunchpadScriptLayer,130 LaunchpadScriptLayer,
@@ -1394,49 +1386,6 @@
1394 self._test_LiveFSFilePruner(1386 self._test_LiveFSFilePruner(
1395 'application/octet-stream', 0, expected_count=1)1387 'application/octet-stream', 0, expected_count=1)
13961388
1397 def test_PersonSettingsENFPopulator(self):
1398 switch_dbuser('testadmin')
1399 store = IMasterStore(PersonSettings)
1400 people_enf_none = []
1401 people_enf_false = []
1402 people_enf_true = []
1403 for _ in range(2):
1404 person = self.factory.makePerson()
1405 try:
1406 person.expanded_notification_footers = None
1407 except NoneError:
1408 # Now enforced by DB NOT NULL constraint; backfilling is no
1409 # longer necessary.
1410 return
1411 people_enf_none.append(person)
1412 person = self.factory.makePerson()
1413 person.expanded_notification_footers = False
1414 people_enf_false.append(person)
1415 person = self.factory.makePerson()
1416 person.expanded_notification_footers = True
1417 people_enf_true.append(person)
1418 settings_count = store.find(PersonSettings).count()
1419 self.runDaily()
1420 switch_dbuser('testadmin')
1421
1422 # No rows have been deleted.
1423 self.assertEqual(settings_count, store.find(PersonSettings).count())
1424
1425 def _assert_enf_by_person(person, expected):
1426 record = store.find(
1427 PersonSettings, PersonSettings.person == person.id).one()
1428 self.assertEqual(expected, record.expanded_notification_footers)
1429
1430 # Rows with expanded_notification_footers=None have been backfilled.
1431 for person in people_enf_none:
1432 _assert_enf_by_person(person, False)
1433
1434 # Other rows have been left alone.
1435 for person in people_enf_false:
1436 _assert_enf_by_person(person, False)
1437 for person in people_enf_true:
1438 _assert_enf_by_person(person, True)
1439
14401389
1441class TestGarboTasks(TestCaseWithFactory):1390class TestGarboTasks(TestCaseWithFactory):
1442 layer = LaunchpadZopelessLayer1391 layer = LaunchpadZopelessLayer