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

Proposed by Robert Collins
Status: Merged
Approved by: Stuart Bishop
Approved revision: no longer in the source branch.
Merged at revision: 10374
Proposed branch: lp:~lifeless/launchpad/bug-618406
Merge into: lp:launchpad/db-devel
Diff against target: 71 lines (+12/-5)
2 files modified
lib/lp/bugs/browser/bugtarget.py (+1/-1)
lib/lp/bugs/model/bugtask.py (+11/-4)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-618406
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Abstain
Stuart Bishop (community) Approve
Review via email: mp+55703@code.launchpad.net

Commit message

[r=stub][bug=618406] Use Bugtask.heat for hottest-bug sorts.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Seems fine. Tests will tell if this breaks anything.

review: Approve
Revision history for this message
Jonathan Lange (jml) wrote :

Sorry, I don't understand this patch. In particular...

 * Why add 'task' to the ordering of BugTaskSearchParams?
 * Why add 'BugTask.bugID' *and* 'Bug.id' to the unambiguous columns?

review: Abstain
Revision history for this message
Robert Collins (lifeless) wrote :

@jml for the former to force a particular unambiguous sort and the for the latter because they are unambiguous columns. This all pertains to the indices chosen for queries - see the attached bug for the gory analysis.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtarget.py'
2--- lib/lp/bugs/browser/bugtarget.py 2011-03-28 23:00:58 +0000
3+++ lib/lp/bugs/browser/bugtarget.py 2011-03-31 08:21:15 +0000
4@@ -1347,7 +1347,7 @@
5 """Return a dict of the 10 hottest tasks and a has_more_bugs flag."""
6 has_more_bugs = False
7 params = BugTaskSearchParams(
8- orderby='-heat', omit_dupes=True,
9+ orderby=['-heat', 'task'], omit_dupes=True,
10 user=self.user, status=any(*UNRESOLVED_BUGTASK_STATUSES))
11 # Use 4x as many tasks as bugs that are needed to improve performance.
12 bugtasks = self.context.searchTasks(params)[:40]
13
14=== modified file 'lib/lp/bugs/model/bugtask.py'
15--- lib/lp/bugs/model/bugtask.py 2011-03-29 05:38:15 +0000
16+++ lib/lp/bugs/model/bugtask.py 2011-03-31 08:21:15 +0000
17@@ -29,6 +29,7 @@
18 import pytz
19 from sqlobject import (
20 ForeignKey,
21+ IntCol,
22 SQLObjectNotFound,
23 StringCol,
24 )
25@@ -544,6 +545,7 @@
26 storm_validator=validate_conjoined_attribute)
27 date_left_closed = UtcDateTimeCol(notNull=False, default=None,
28 storm_validator=validate_conjoined_attribute)
29+ heat = IntCol(notNull=True, default=0)
30 owner = ForeignKey(
31 dbName='owner', foreignKey='Person',
32 storm_validator=validate_public_person, notNull=True)
33@@ -2917,6 +2919,7 @@
34 # Local import of Bug to avoid import loop.
35 from lp.bugs.model.bug import Bug
36 BugTaskSet._ORDERBY_COLUMN = {
37+ "task": BugTask.id,
38 "id": BugTask.bugID,
39 "importance": BugTask.importance,
40 # TODO: sort by their name?
41@@ -2932,7 +2935,7 @@
42 "number_of_duplicates": Bug.number_of_duplicates,
43 "message_count": Bug.message_count,
44 "users_affected_count": Bug.users_affected_count,
45- "heat": Bug.heat,
46+ "heat": BugTask.heat,
47 "latest_patch_uploaded": Bug.latest_patch_uploaded,
48 }
49 return BugTaskSet._ORDERBY_COLUMN[col_name]
50@@ -2957,14 +2960,18 @@
51 # This set contains columns which are, in practical terms,
52 # unique. When these columns are used as sort keys, they ensure
53 # the sort will be consistent. These columns will be used to
54- # decide whether we need to add the BugTask.bug and BugTask.id
55+ # decide whether we need to add the BugTask.bug or BugTask.id
56 # columns to make the sort consistent over runs -- which is good
57 # for the user and essential for the test suite.
58 unambiguous_cols = set([
59+ Bug.date_last_updated,
60+ Bug.datecreated,
61+ Bug.id,
62+ BugTask.bugID,
63 BugTask.date_assigned,
64 BugTask.datecreated,
65- Bug.datecreated,
66- Bug.date_last_updated])
67+ BugTask.id,
68+ ])
69 # Bug ID is unique within bugs on a product or source package.
70 if (params.product or
71 (params.distribution and params.sourcepackagename) or

Subscribers

People subscribed via source and target branches

to status/vote changes: