Merge lp:~wgrant/launchpad/bugtaskflat-join-removal into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 15129
Proposed branch: lp:~wgrant/launchpad/bugtaskflat-join-removal
Merge into: lp:launchpad
Diff against target: 39 lines (+8/-7)
1 file modified
lib/lp/bugs/model/bugtasksearch.py (+8/-7)
To merge this branch: bzr merge lp:~wgrant/launchpad/bugtaskflat-join-removal
Reviewer Review Type Date Requested Status
Ian Booth (community) Approve
Review via email: mp+102780@code.launchpad.net

Commit message

Only join Bug and BugTask when searching BugTaskFlat if we actually need them.

Description of the change

I accidentally left Bug and BugTask joins in the BugTaskFlat sorting code. This branch removes them.

Two filtering cases still require it (BugTask.date_closed and Bug.latest_patch_uploaded), since they're not (yet?) denormalised on BugTaskFlat. I've changed them to join it themselves.

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/model/bugtasksearch.py'
2--- lib/lp/bugs/model/bugtasksearch.py 2012-04-19 04:00:08 +0000
3+++ lib/lp/bugs/model/bugtasksearch.py 2012-04-19 23:46:20 +0000
4@@ -516,6 +516,11 @@
5 if where_cond is not None:
6 extra_clauses.append(where_cond)
7
8+ # All the standard args filter on BugTaskFlat, except for
9+ # date_closed which isn't denormalised (yet?).
10+ if params.date_closed is not None and use_flat:
11+ join_tables.append(flat_bugtask_join)
12+
13 if params.status is not None:
14 extra_clauses.append(
15 _build_status_clause(cols['BugTask._status'], params.status))
16@@ -601,6 +606,8 @@
17 if params.attachmenttype is not None:
18 if params.attachmenttype == BugAttachmentType.PATCH:
19 extra_clauses.append(Bug.latest_patch_uploaded != None)
20+ if use_flat:
21+ join_tables.append(flat_bug_join)
22 else:
23 extra_clauses.append(
24 cols['Bug.id'].is_in(
25@@ -964,13 +971,7 @@
26
27 # Translate orderby keys into corresponding Table.attribute
28 # strings.
29- if use_flat:
30- extra_joins = [
31- (Bug, Join(Bug, Bug.id == BugTaskFlat.bug_id)),
32- (BugTask, Join(BugTask, BugTask.id == BugTaskFlat.bugtask_id)),
33- ]
34- else:
35- extra_joins = []
36+ extra_joins = []
37 ambiguous = True
38 # Sorting by milestone only is a very "coarse" sort order.
39 # If no additional sort order is specified, add the bug task