Merge lp://staging/~gary/launchpad/bug741684-3 into lp://staging/launchpad

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 12733
Proposed branch: lp://staging/~gary/launchpad/bug741684-3
Merge into: lp://staging/launchpad
Diff against target: 467 lines (+189/-115)
5 files modified
lib/lp/bugs/interfaces/bugnotification.py (+9/-3)
lib/lp/bugs/model/bugnotification.py (+61/-10)
lib/lp/bugs/scripts/bugnotification.py (+31/-41)
lib/lp/bugs/scripts/tests/test_bugnotification.py (+4/-3)
lib/lp/bugs/tests/test_bugnotification.py (+84/-58)
To merge this branch: bzr merge lp://staging/~gary/launchpad/bug741684-3
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+55935@code.staging.launchpad.net

Commit message

[r=bac][bug=741684,742230] Further optimize the notification script code.

Description of the change

This branch changes how we get filter information for each email recipient one more time. Now, instead of making a query per subscription source, we make a single query for an entire batched set of notifications. We then assemble the data into the structure we actually want per recipient.

Part of the structure of the new method, and how it is used, is coming from the fact that I'm preparing to add additional functionality to it in a db-devel branch, but I think it stands up well enough on its own.

Almost all the code in this branch is about that change, either directly or indirectly (tests).

The only exception is that lib/lp/bugs/scripts/bugnotification.py also contains some changes because I was tired about being confused about the "recipients" name. The notification.recipients collection is actually a collection of objects that describe the subscriptions that will be affected by the notification. Each "recipient" has more information than just the principal involved in the subscription (including the rationale, for instance) and also, in this script, the "recipients" are exploded out into the people who actually receive the emails. Therefore, while the "recipients" collection on each notification makes some sense as a name on the notification, it was getting confusing within the script itself. I decided to call these objects "sources" and the people who would actually receive the mail "recipients".

I would have preferred to have getRecipientFilterData be a function for simplicity, but in this case it was actually nice to have it on a utility so I could use dependency injection within one of the tests. That said, given that there's no machinery to automatically undo the utility registration, it is interesting to note that there's no practical advantage to this pattern over monkeypatching, which is a bit sad.

Thank you!

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Gary this branch looks good. On IRC we discussed the oddity of the bare assert statement in your test. Please either put in a comment explaining why it is there or change it to self.assertEqual.

review: Approve (code)
Revision history for this message
Robert Collins (lifeless) wrote :

There is a Fixture to register and unregister a utility around in the
tree somewhere, I think its bundled in with the fake librarian tests
at the moment.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.