Merge lp:~allenap/launchpad/bugsubscription-to-storm into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Gavin Panella on 2010-09-17 | ||||
| Approved revision: | no longer in the source branch. | ||||
| Merged at revision: | 11646 | ||||
| Proposed branch: | lp:~allenap/launchpad/bugsubscription-to-storm | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
598 lines (+123/-88) 17 files modified
lib/lp/bugs/browser/bug.py (+2/-2) lib/lp/bugs/browser/bugsubscription.py (+4/-1) lib/lp/bugs/browser/tests/bug-portlet-subscribers-content.txt (+2/-2) lib/lp/bugs/browser/tests/bug-views.txt (+3/-3) lib/lp/bugs/browser/tests/bugs-views.txt (+1/-1) lib/lp/bugs/browser/tests/person-bug-views.txt (+1/-1) lib/lp/bugs/doc/bugnotification-sending.txt (+4/-4) lib/lp/bugs/doc/bugsubscription.txt (+7/-7) lib/lp/bugs/doc/bugtask-expiration.txt (+1/-1) lib/lp/bugs/doc/milestones-from-bugtask-search.txt (+1/-1) lib/lp/bugs/model/bug.py (+33/-32) lib/lp/bugs/model/bugsubscription.py (+37/-23) lib/lp/bugs/model/bugtask.py (+2/-2) lib/lp/bugs/tests/bugs-emailinterface.txt (+1/-1) lib/lp/bugs/tests/test_bug.py (+17/-0) lib/lp/hardwaredb/doc/hwdb-device-tables.txt (+5/-5) lib/lp/hardwaredb/model/hwdb.py (+2/-2) |
||||
| To merge this branch: | bzr merge lp:~allenap/launchpad/bugsubscription-to-storm | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code | 2010-09-15 | Approve on 2010-09-16 |
|
Review via email:
|
|||
Commit Message
Change BugSubscription to a regular Storm model object; it no longer uses the SQLObject shim.
Description of the Change
This converts BugSubscription to inherit from Storm instead of SQLObject.
| Robert Collins (lifeless) wrote : | # |
| Gavin Panella (allenap) wrote : | # |
@Rob BugSubscription doesn't use any cached properties, so I don't follow. We can switch the base class at a later date, en masse, when one is available. Would that work? I suspect I'm missing something.
| Robert Collins (lifeless) wrote : | # |
On Thu, Sep 16, 2010 at 8:36 PM, Gavin Panella
<email address hidden> wrote:
> @Rob BugSubscription doesn't use any cached properties, so I don't follow. We can switch the base class at a later date, en masse, when one is available. Would that work? I suspect I'm missing something.
That would be fine; I'm just sensitised to the lack and hoping someone
else will do it ;)
-Rob
| Michael Nelson (michael.nelson) wrote : | # |
Hi Gavin,
r=me, great to see it being stormified :) I've got one thought that you might want to try below.
Cheers,
Michael
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -730,27 +737,28 @@
> """See `IBug`."""
> if self.private:
> return []
> -
> - duplicate_
> - BugSubscription
> - BugSubscription.bug = Bug.id AND
> - Bug.duplicateof = %d""" % self.id,
> - prejoins=
> -
> - # Only add a subscriber once to the list.
> - duplicate_
> - sub.person for sub in duplicate_
> - subscriptions = []
> - for duplicate_
> - for duplicate_
> - if duplicate_
> - subscriptions.
> - break
> -
> - def get_person_
> - return subscription.
> -
> - return sorted(
> + # Get bug subscribers and subscriptions for duplicates.
> + subscribers_
> + IStore(
> + (Person, BugSubscription),
> + BugSubscription
> + BugSubscription
> + Bug.duplicateof == self).order_by(
> + Person.id, BugSubscription
> + # Generator for the subscription objects alone. The subscribers
> + # (Person objects) are loaded to warm up the cache only.
> + subscriptions = (
> + subscription for subscriber, subscription in (
> + subscribers_
> + # Group by the subscriber. The results are ordered by subscriber and
> + # subscription id, so we can grab the earliest subscription for a
> + # subscriber (and that the results of this method are stable).
> + subscriptions = (
> + list(subscripti
> + subscriptions, key=operator.
> + # Sort by the subscriber's display name.
> + return sorted(
> + subscriptions, key=operator.
We chatted about this:
{{{
14:42 < noodles775> allenap: what order of subscriptions are returned by getSubscription
14:43 * allenap looks
14:44 < noodles775> sorry, I meant how many subscriptions - and whether it's currently a method with performance issues or not.
14:46 < allenap> noodles775: I don't know if it has performance problems, but the code certainly appears sub-optimal. It should return one subscription per subscriber. Each subscriber could have more than one subscription so I've ensured that the earliest is always returned. I /think/ it was undefined before.
}}}...
| Robert Collins (lifeless) wrote : | # |
ugh, nooo
just do
DISTINCT ON
If the contract is 'return on subscription per subscriber' your
DISTINCT ON clause will want to be (subscriber.id) [e.g. Person.id, or
TeamParticipati
-Rob
| Michael Nelson (michael.nelson) wrote : | # |
On Fri, Sep 17, 2010 at 2:09 AM, Robert Collins
<email address hidden> wrote:
> ugh, nooo
>
> just do
> DISTINCT ON
>
> If the contract is 'return on subscription per subscriber' your
> DISTINCT ON clause will want to be (subscriber.id) [e.g. Person.id, or
> TeamParticipati
Even better - I'd not seen DISTINCT ON before. Just read a bit more
about this exact issue here:
http://
Cheers,
M.
| Gavin Panella (allenap) wrote : | # |
Oh yes, thanks Rob. I feel a bit foolish; I've used it before :)

We can't really do this till we have a clean base class that hooks
into the IPropertyCache clear. :(