← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/bug-606914 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/bug-606914 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
  #606914 Bug.initial_message fetches all of the bug's messages
  https://bugs.launchpad.net/bugs/606914


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.
-- 
https://code.launchpad.net/~gmb/launchpad/bug-606914/+merge/30259
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/bug-606914 into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py	2010-07-14 12:00:01 +0000
+++ lib/lp/bugs/model/bug.py	2010-07-19 11:50:34 +0000
@@ -494,8 +494,13 @@
     @property
     def initial_message(self):
         """See `IBug`."""
-        messages = sorted(self.messages, key=lambda ob: ob.id)
-        return messages[0]
+        store = Store.of(self)
+        messages = store.find(
+            Message,
+            BugMessage.bug == self,
+            BugMessage.message == Message.id).order_by('id')
+
+        return messages.first()
 
     def followup_subject(self):
         """See `IBug`."""


Follow ups