launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05920
lp:~allenap/launchpad/bugnomination-timeout-bug-874250-heat-death into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/bugnomination-timeout-bug-874250-heat-death into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #874250 in Launchpad itself: "BugNomination:+editstatus timeout for bugs with many tasks"
https://bugs.launchpad.net/launchpad/+bug/874250
For more details, see:
https://code.launchpad.net/~allenap/launchpad/bugnomination-timeout-bug-874250-heat-death/+merge/85497
I missed this in an earlier branch that converted HasBugHeatMixin.
recalculateBugHeatCache() to use Storm lazy expression values;
DistroSeriesSourcePackage has its own recalculateBugHeatCache().
It passes in ec2.
--
https://code.launchpad.net/~allenap/launchpad/bugnomination-timeout-bug-874250-heat-death/+merge/85497
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/bugnomination-timeout-bug-874250-heat-death into lp:launchpad.
=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
--- lib/lp/registry/model/distributionsourcepackage.py 2011-11-24 00:51:13 +0000
+++ lib/lp/registry/model/distributionsourcepackage.py 2011-12-13 14:38:08 +0000
@@ -21,10 +21,13 @@
from sqlobject.sqlbuilder import SQLConstant
from storm.expr import (
And,
+ Coalesce,
Count,
Desc,
Max,
+ Select,
Sum,
+ Union,
)
from storm.locals import (
Bool,
@@ -238,21 +241,22 @@
def recalculateBugHeatCache(self):
"""See `IHasBugHeat`."""
- row = IStore(Bug).find(
- (Max(Bug.heat), Sum(Bug.heat), Count(Bug.id)),
+ conditions = And(
BugTask.bug == Bug.id,
BugTask.distributionID == self.distribution.id,
BugTask.sourcepackagenameID == self.sourcepackagename.id,
- Bug.duplicateof == None,
- BugTask._status.is_in(DB_UNRESOLVED_BUGTASK_STATUSES)).one()
-
- # Aggregate functions return NULL if zero rows match.
- row = list(row)
- for i in range(len(row)):
- if row[i] is None:
- row[i] = 0
-
- self.max_bug_heat, self.total_bug_heat, self.bug_count = row
+ BugTask._status.is_in(DB_UNRESOLVED_BUGTASK_STATUSES),
+ Bug.duplicateof == None)
+ # Use Storm's lazy expression values
+ # <https://storm.canonical.com/Tutorial#Expression_values>.
+ # XXX: GavinPanella 2011-12-12 bug=???: The use of Union is a hack to
+ # get Storm to add braces around the expression.
+ self.max_bug_heat = Union(
+ Select(Coalesce(Max(Bug.heat), 0), conditions))
+ self.total_bug_heat = Union(
+ Select(Coalesce(Sum(Bug.heat), 0), conditions))
+ self.bug_count = Union(
+ Select(Coalesce(Count(Bug.id), 0), conditions))
@property
def latest_overall_publication(self):