launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02696
[Merge] lp:~lifeless/launchpad/bug-717394-2 into lp:launchpad
Robert Collins has proposed merging lp:~lifeless/launchpad/bug-717394-2 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~lifeless/launchpad/bug-717394-2/+merge/50545
use the pillar rather than collating across series to get milestones - drops another query per series from bug searches.
--
https://code.launchpad.net/~lifeless/launchpad/bug-717394-2/+merge/50545
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-717394-2 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 02:07:05 +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
@@ -1178,6 +1181,20 @@
return list(series)
@property
+ def milestones_list(self):
+ if IDistribution(self.context, None):
+ milestone_resultset = self.context.milestones
+ elif IProduct(self.context, None):
+ milestone_resultset = self.context.milestones
+ elif IDistroSeries(self.context, None):
+ milestone_resultset = self.context.distribution.milestones
+ elif IProductSeries(self.context, None):
+ milestone_resultset = self.context.product.milestones
+ else:
+ raise AssertionError("series_list called with illegal context")
+ return list(milestone_resultset)
+
+ @property
def series_buglistings(self):
"""Return a buglisting for each series.
@@ -1218,16 +1235,20 @@
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 = self.milestones_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 02:07:05 +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 02:07:05 +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 02:07:05 +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