← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~lifeless/launchpad/bug-618406 into lp:launchpad/db-devel

 

Robert Collins has proposed merging lp:~lifeless/launchpad/bug-618406 into lp:launchpad/db-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #618406 in Launchpad itself: "Distribution:+bugs-index time outs"
  https://bugs.launchpad.net/launchpad/+bug/618406

For more details, see:
https://code.launchpad.net/~lifeless/launchpad/bug-618406/+merge/55703

This branch activates the new bugtask.heat column in bug sorts; there is a bit of action-at-a-distance involved, so we may need to revisit this and actually have a bug-heat and bugtask-heat for different queries (specifically the unique-in-context logic means we'll generate 'bugtask.heat desc, bugtask.bug' sort orders for product or sourcepackage scoped queries, None of those scopes have the overwhelming volume of bugs that Ubuntu does, so we can tolerate that and add indices if needed subsequently.
-- 
https://code.launchpad.net/~lifeless/launchpad/bug-618406/+merge/55703
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-618406 into lp:launchpad/db-devel.
=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py	2011-03-28 23:00:58 +0000
+++ lib/lp/bugs/browser/bugtarget.py	2011-03-31 08:21:15 +0000
@@ -1347,7 +1347,7 @@
         """Return a dict of the 10 hottest tasks and a has_more_bugs flag."""
         has_more_bugs = False
         params = BugTaskSearchParams(
-            orderby='-heat', omit_dupes=True,
+            orderby=['-heat', 'task'], omit_dupes=True,
             user=self.user, status=any(*UNRESOLVED_BUGTASK_STATUSES))
         # Use 4x as many tasks as bugs that are needed to improve performance.
         bugtasks = self.context.searchTasks(params)[:40]

=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py	2011-03-29 05:38:15 +0000
+++ lib/lp/bugs/model/bugtask.py	2011-03-31 08:21:15 +0000
@@ -29,6 +29,7 @@
 import pytz
 from sqlobject import (
     ForeignKey,
+    IntCol,
     SQLObjectNotFound,
     StringCol,
     )
@@ -544,6 +545,7 @@
         storm_validator=validate_conjoined_attribute)
     date_left_closed = UtcDateTimeCol(notNull=False, default=None,
         storm_validator=validate_conjoined_attribute)
+    heat = IntCol(notNull=True, default=0)
     owner = ForeignKey(
         dbName='owner', foreignKey='Person',
         storm_validator=validate_public_person, notNull=True)
@@ -2917,6 +2919,7 @@
             # Local import of Bug to avoid import loop.
             from lp.bugs.model.bug import Bug
             BugTaskSet._ORDERBY_COLUMN = {
+                "task": BugTask.id,
                 "id": BugTask.bugID,
                 "importance": BugTask.importance,
                 # TODO: sort by their name?
@@ -2932,7 +2935,7 @@
                 "number_of_duplicates": Bug.number_of_duplicates,
                 "message_count": Bug.message_count,
                 "users_affected_count": Bug.users_affected_count,
-                "heat": Bug.heat,
+                "heat": BugTask.heat,
                 "latest_patch_uploaded": Bug.latest_patch_uploaded,
                 }
         return BugTaskSet._ORDERBY_COLUMN[col_name]
@@ -2957,14 +2960,18 @@
         # This set contains columns which are, in practical terms,
         # unique. When these columns are used as sort keys, they ensure
         # the sort will be consistent. These columns will be used to
-        # decide whether we need to add the BugTask.bug and BugTask.id
+        # decide whether we need to add the BugTask.bug or BugTask.id
         # columns to make the sort consistent over runs -- which is good
         # for the user and essential for the test suite.
         unambiguous_cols = set([
+            Bug.date_last_updated,
+            Bug.datecreated,
+            Bug.id,
+            BugTask.bugID,
             BugTask.date_assigned,
             BugTask.datecreated,
-            Bug.datecreated,
-            Bug.date_last_updated])
+            BugTask.id,
+            ])
         # Bug ID is unique within bugs on a product or source package.
         if (params.product or
             (params.distribution and params.sourcepackagename) or