launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03028
[Merge] lp:~lifeless/launchpad/bug-739799 into lp:launchpad
Robert Collins has proposed merging lp:~lifeless/launchpad/bug-739799 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #739799 in Launchpad itself: "BranchMergeProposal:+index timeout"
https://bugs.launchpad.net/launchpad/+bug/739799
For more details, see:
https://code.launchpad.net/~lifeless/launchpad/bug-739799/+merge/54287
sequential scans are bad mmkay.
--
https://code.launchpad.net/~lifeless/launchpad/bug-739799/+merge/54287
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-739799 into lp:launchpad.
=== modified file 'lib/canonical/launchpad/components/decoratedresultset.py'
--- lib/canonical/launchpad/components/decoratedresultset.py 2010-09-15 10:06:34 +0000
+++ lib/canonical/launchpad/components/decoratedresultset.py 2011-03-22 00:26:34 +0000
@@ -41,7 +41,8 @@
:param result_decorator: The method with which individual results
will be passed through before being returned.
:param pre_iter_hook: The method to be called (with the 'result_set')
- immediately before iteration starts.
+ immediately before iteration starts. The return value of the hook
+ is ignored.
:param slice_info: If True pass information about the slice parameters
to the result_decorator and pre_iter_hook. any() and similar
methods will cause None to be supplied.
=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py 2011-03-03 01:13:47 +0000
+++ lib/lp/code/interfaces/branch.py 2011-03-22 00:26:34 +0000
@@ -623,8 +623,7 @@
:param end_date: Return revisions that were committed before the
end_date
:param oldest_first: Defines the ordering of the result set.
- :returns: A resultset of tuples for
- (BranchRevision, Revision, RevisionAuthor)
+ :returns: A resultset of tuples for (BranchRevision, Revision)
"""
def getRevisionsSince(timestamp):
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2011-03-21 03:50:10 +0000
+++ lib/lp/code/model/branch.py 2011-03-22 00:26:34 +0000
@@ -139,6 +139,7 @@
validate_person,
validate_public_person,
)
+from lp.services.database.bulk import load_related
from lp.services.job.interfaces.job import JobStatus
from lp.services.job.model.job import Job
from lp.services.mail.notificationrecipientset import NotificationRecipientSet
@@ -579,17 +580,19 @@
if end_date is not None:
date_clause = And(date_clause, Revision.revision_date <= end_date)
result = Store.of(self).find(
- (BranchRevision, Revision, RevisionAuthor),
+ (BranchRevision, Revision),
BranchRevision.branch == self,
BranchRevision.sequence != None,
BranchRevision.revision == Revision.id,
- Revision.revision_author == RevisionAuthor.id,
date_clause)
if oldest_first:
result = result.order_by(BranchRevision.sequence)
else:
result = result.order_by(Desc(BranchRevision.sequence))
- return result
+ def eager_load(rows):
+ revisions = map(operator.itemgetter(1), rows)
+ load_related(RevisionAuthor, revisions, ['revision_author_id'])
+ return DecoratedResultSet(result, pre_iter_hook=eager_load)
def getRevisionsSince(self, timestamp):
"""See `IBranch`."""
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2011-03-21 04:38:21 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2011-03-22 00:26:34 +0000
@@ -881,10 +881,10 @@
entries.extend(
((revision.date_created, branch_revision.sequence),
branch_revision)
- for branch_revision, revision, revision_author in revisions)
+ for branch_revision, revision in revisions)
entries.sort()
current_group = []
- for date, entry in entries:
+ for sortkey, entry in entries:
if IBranchRevision.providedBy(entry):
current_group.append(entry)
else:
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2011-03-21 11:13:36 +0000
+++ lib/lp/code/model/tests/test_branch.py 2011-03-22 00:26:34 +0000
@@ -2641,7 +2641,7 @@
new = add_revision_to_branch(
self.factory, branch, epoch + timedelta(days=1))
result = branch.getMainlineBranchRevisions(epoch)
- branch_revisions = [br for br, rev, ra in result]
+ branch_revisions = [br for br, rev in result]
self.assertEqual([new], branch_revisions)
def test_end_date(self):
@@ -2655,7 +2655,7 @@
add_revision_to_branch(
self.factory, branch, end_date + timedelta(days=1))
result = branch.getMainlineBranchRevisions(epoch, end_date)
- branch_revisions = [br for br, rev, ra in result]
+ branch_revisions = [br for br, rev in result]
self.assertEqual([in_range], branch_revisions)
def test_newest_first(self):
@@ -2667,7 +2667,7 @@
new = add_revision_to_branch(
self.factory, branch, epoch + timedelta(days=2))
result = branch.getMainlineBranchRevisions(epoch, oldest_first=False)
- branch_revisions = [br for br, rev, ra in result]
+ branch_revisions = [br for br, rev in result]
self.assertEqual([new, old], branch_revisions)
def test_oldest_first(self):
@@ -2679,7 +2679,7 @@
new = add_revision_to_branch(
self.factory, branch, epoch + timedelta(days=2))
result = branch.getMainlineBranchRevisions(epoch, oldest_first=True)
- branch_revisions = [br for br, rev, ra in result]
+ branch_revisions = [br for br, rev in result]
self.assertEqual([old, new], branch_revisions)
def test_only_mainline_revisions(self):
@@ -2694,7 +2694,7 @@
new = add_revision_to_branch(
self.factory, branch, epoch + timedelta(days=3))
result = branch.getMainlineBranchRevisions(epoch)
- branch_revisions = [br for br, rev, ra in result]
+ branch_revisions = [br for br, rev in result]
self.assertEqual([new, old], branch_revisions)
=== modified file 'lib/lp/services/database/bulk.py'
--- lib/lp/services/database/bulk.py 2011-03-21 03:12:40 +0000
+++ lib/lp/services/database/bulk.py 2011-03-22 00:26:34 +0000
@@ -6,6 +6,7 @@
__metaclass__ = type
__all__ = [
'load',
+ 'load_related',
'reload',
]