← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/moar-preload-people-branch-index into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/moar-preload-people-branch-index into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/moar-preload-people-branch-index/+merge/150953

No longer use hasSubscription to check if Branch:+index should link to '+edit-subscription' rather than '+subscribe'.
-- 
https://code.launchpad.net/~stevenk/launchpad/moar-preload-people-branch-index/+merge/150953
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/moar-preload-people-branch-index into lp:launchpad.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py	2013-02-25 05:23:12 +0000
+++ lib/lp/code/browser/branch.py	2013-02-28 04:07:23 +0000
@@ -330,7 +330,8 @@
 
     @enabled_with_permission('launchpad.AnyPerson')
     def subscription(self):
-        if self.context.hasSubscription(self.user):
+        person_ids = [sub.personID for sub in self.context.subscriptions]
+        if self.user and self.user.id in person_ids:
             url = '+edit-subscription'
             text = 'Edit your subscription'
             icon = 'edit'

=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py	2013-02-26 03:20:44 +0000
+++ lib/lp/code/browser/tests/test_branch.py	2013-02-28 04:07:23 +0000
@@ -548,6 +548,19 @@
             view.render()
         self.assertThat(recorder, HasQueryCount(Equals(9)))
 
+    def test_query_count_index_with_subscribers(self):
+        branch = self.factory.makeBranch()
+        for i in range(10):
+            self.factory.makeBranchSubscription(branch=branch)
+        Store.of(branch).flush()
+        Store.of(branch).invalidate()
+        branch_url = canonical_url(branch, view_name='+index', rootsite='code')
+        browser = setupBrowser()
+        logout()
+        with StormStatementRecorder() as recorder:
+            browser.open(branch_url)
+        self.assertThat(recorder, HasQueryCount(Equals(26)))
+
 
 class TestBranchViewPrivateArtifacts(BrowserTestCase):
     """ Tests that branches with private team artifacts can be viewed.


Follow ups