launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02693
[Merge] lp:~lifeless/launchpad/bug-717394 into lp:launchpad
Robert Collins has proposed merging lp:~lifeless/launchpad/bug-717394 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#717394 Distribution:+bugs timeouts
https://bugs.launchpad.net/bugs/717394
For more details, see:
https://code.launchpad.net/~lifeless/launchpad/bug-717394/+merge/50541
Another step on bug search performance, this branch uses the relatively new counting API for bugs to get aggregates for milestones rather than querying once per milestone. This should save nearly a second on bug searches in the Ubuntu context and help make bug searches in smaller contexts just that little bit snappier.
--
https://code.launchpad.net/~lifeless/launchpad/bug-717394/+merge/50541
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-717394 into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py 2011-02-17 09:14:19 +0000
+++ lib/lp/bugs/browser/bugtarget.py 2011-02-21 01:16:19 +0000
@@ -24,7 +24,10 @@
import cgi
from cStringIO import StringIO
from datetime import datetime
-from operator import itemgetter
+from operator import (
+ attrgetter,
+ itemgetter,
+ )
import urllib
from lazr.restful.interface import copy_field
@@ -1218,16 +1221,22 @@
def milestone_buglistings(self):
"""Return a buglisting for each milestone."""
milestone_buglistings = []
- for series in self.series_list:
- for milestone in series.milestones:
- milestone_bug_count = milestone.open_bugtasks.count()
- if milestone_bug_count > 0:
- milestone_buglistings.append(
- dict(
- title=milestone.name,
- url=canonical_url(milestone),
- count=milestone_bug_count,
- ))
+ bug_task_set = getUtility(IBugTaskSet)
+ milestones = []
+ reduce(lambda _, series:milestones.extend(series.milestones),
+ self.series_list, [])
+ open_bugs = bug_task_set.open_bugtask_search
+ open_bugs.setTarget(any(*milestones))
+ counts = bug_task_set.countBugs(open_bugs, (BugTask.milestoneID,))
+ for milestone in milestones:
+ milestone_bug_count = counts.get((milestone.id,), 0)
+ if milestone_bug_count > 0:
+ milestone_buglistings.append(
+ dict(
+ title=milestone.name,
+ url=canonical_url(milestone),
+ count=milestone_bug_count,
+ ))
return milestone_buglistings
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2011-02-18 02:58:59 +0000
+++ lib/lp/bugs/browser/bugtask.py 2011-02-21 01:16:19 +0000
@@ -3078,12 +3078,11 @@
# XXX flacoste 2008/04/24 This should be moved to a
# BugTaskSearchParams.setTarget().
- if IDistroSeries.providedBy(self.context):
- search_params.setDistroSeries(self.context)
+ if (IDistroSeries.providedBy(self.context) or
+ IProductSeries.providedBy(self.context)):
+ search_params.setTarget(self.context)
elif IDistribution.providedBy(self.context):
search_params.setDistribution(self.context)
- elif IProductSeries.providedBy(self.context):
- search_params.setProductSeries(self.context)
elif IProduct.providedBy(self.context):
search_params.setProduct(self.context)
elif IProjectGroup.providedBy(self.context):
=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
--- lib/lp/bugs/interfaces/bugtask.py 2011-02-17 09:14:19 +0000
+++ lib/lp/bugs/interfaces/bugtask.py 2011-02-21 01:16:19 +0000
@@ -1281,6 +1281,7 @@
# Yay circular deps.
from lp.registry.interfaces.distroseries import IDistroSeries
from lp.registry.interfaces.productseries import IProductSeries
+ from lp.registry.interfaces.milestone import IMilestone
if isinstance(target, (any, all)):
assert len(target.query_values), \
'cannot determine target with no targets'
@@ -1291,6 +1292,8 @@
self.setDistroSeries(target)
elif IProductSeries.providedBy(instance):
self.setProductSeries(target)
+ elif IMilestone.providedBy(instance):
+ self.milestone = target
else:
raise AssertionError("unknown target type %r" % target)
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2011-02-17 04:40:55 +0000
+++ lib/lp/bugs/model/bugtask.py 2011-02-21 01:16:19 +0000
@@ -2502,7 +2502,7 @@
def countBugs(self, params, group_on):
"""See `IBugTaskSet`."""
resultset = self._search(
- group_on + (Count(BugTask.bugID),), [], None, params).result_set
+ group_on + (SQL("COUNT(Distinct BugTask.bug)"),), [], None, params).result_set
# We group on the related field:
resultset.group_by(*group_on)
resultset.order_by()
Follow ups