← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/bug-615644 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/bug-615644 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
  #615644 BugTask:+distrotask timeout on HEAT lookup
  https://bugs.launchpad.net/bugs/615644


This branch fixes bug 615644 by changing the queries used to get the maximum heat for a target (see the bug for Stub's description of the fix).
-- 
https://code.launchpad.net/~gmb/launchpad/bug-615644/+merge/32175
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/bug-615644 into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugtarget.py'
--- lib/lp/bugs/model/bugtarget.py	2010-06-25 18:48:13 +0000
+++ lib/lp/bugs/model/bugtarget.py	2010-08-10 09:14:01 +0000
@@ -251,29 +251,25 @@
             return
 
         if IDistribution.providedBy(self):
-            sql = ["""SELECT Bug.heat
+            sql = ["""SELECT MAX(Bug.heat)
                       FROM Bug, Bugtask
                       WHERE Bugtask.bug = Bug.id
-                      AND Bugtask.distribution = %s
-                      ORDER BY Bug.heat DESC LIMIT 1""" % sqlvalues(self),
-                   """SELECT Bug.heat
+                      AND Bugtask.distribution = %s""" % sqlvalues(self),
+                   """SELECT MAX(Bug.heat)
                       FROM Bug, Bugtask, DistroSeries
                       WHERE Bugtask.bug = Bug.id
                       AND Bugtask.distroseries = DistroSeries.id
-                      AND DistroSeries.distribution = %s
-                      ORDER BY Bug.heat DESC LIMIT 1""" % sqlvalues(self)]
+                      AND DistroSeries.distribution = %s""" % sqlvalues(self)]
         elif IProduct.providedBy(self):
-            sql = ["""SELECT Bug.heat
+            sql = ["""SELECT MAX(Bug.heat)
                       FROM Bug, Bugtask
                       WHERE Bugtask.bug = Bug.id
-                      AND Bugtask.product = %s
-                      ORDER BY Bug.heat DESC LIMIT 1""" % sqlvalues(self),
-                   """SELECT Bug.heat
+                      AND Bugtask.product = %s""" % sqlvalues(self),
+                   """SELECT MAX(Bug.heat)
                       FROM Bug, Bugtask, ProductSeries
                       WHERE Bugtask.bug = Bug.id
                       AND Bugtask.productseries = ProductSeries.id
-                      AND ProductSeries.product = %s
-                      ORDER BY Bug.heat DESC LIMIT 1""" % sqlvalues(self)]
+                      AND ProductSeries.product = %s""" % sqlvalues(self)]
         elif IProjectGroup.providedBy(self):
             sql = ["""SELECT MAX(heat)
                       FROM Bug, Bugtask, Product


Follow ups