Merge lp:~gmb/launchpad/bug-606914 into lp:launchpad/db-devel

Proposed by Graham Binns on 2010-07-19
Status: Merged
Approved by: Robert Collins on 2010-07-19
Approved revision: no longer in the source branch.
Merged at revision: 9552
Proposed branch: lp:~gmb/launchpad/bug-606914
Merge into: lp:launchpad/db-devel
Diff against target: 18 lines (+6/-2)
1 file modified
lib/lp/bugs/model/bug.py (+6/-2)
To merge this branch: bzr merge lp:~gmb/launchpad/bug-606914
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve on 2010-07-19
Launchpad code reviewers code 2010-07-19 Pending
Review via email: mp+30259@code.launchpad.net

Commit Message

Bug.initial_message has been changed to use Storm rather than materialising and sorting all the messages to then only return one.

Description of the Change

This branch fixes the bizarrely sucky implementation of Bug.initial_message, which previously materialised all the messages, sorted them and then returned the first one. Which is just daft. So I've changed it to use Storm.

There are a lot of tests covering this, but you can run bin/test -cvvt bugs-emailinterface.txt to be sure.

To post a comment you must log in.
Robert Collins (lifeless) wrote :

The VWS on line 15 is a bit jarring. I'd delete it personally.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/model/bug.py'
2--- lib/lp/bugs/model/bug.py 2010-07-14 12:00:01 +0000
3+++ lib/lp/bugs/model/bug.py 2010-07-19 12:11:20 +0000
4@@ -494,8 +494,12 @@
5 @property
6 def initial_message(self):
7 """See `IBug`."""
8- messages = sorted(self.messages, key=lambda ob: ob.id)
9- return messages[0]
10+ store = Store.of(self)
11+ messages = store.find(
12+ Message,
13+ BugMessage.bug == self,
14+ BugMessage.message == Message.id).order_by('id')
15+ return messages.first()
16
17 def followup_subject(self):
18 """See `IBug`."""

Subscribers

People subscribed via source and target branches

to status/vote changes: