← Back to team overview

launchpad-reviewers team mailing list archive

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

 

William Grant has proposed merging lp:~wgrant/launchpad/bugtaskflat-join-removal into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bugtaskflat-join-removal/+merge/102780

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.
-- 
https://code.launchpad.net/~wgrant/launchpad/bugtaskflat-join-removal/+merge/102780
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bugtaskflat-join-removal into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugtasksearch.py'
--- lib/lp/bugs/model/bugtasksearch.py	2012-04-19 04:00:08 +0000
+++ lib/lp/bugs/model/bugtasksearch.py	2012-04-19 23:46:20 +0000
@@ -516,6 +516,11 @@
         if where_cond is not None:
             extra_clauses.append(where_cond)
 
+    # All the standard args filter on BugTaskFlat, except for
+    # date_closed which isn't denormalised (yet?).
+    if params.date_closed is not None and use_flat:
+        join_tables.append(flat_bugtask_join)
+
     if params.status is not None:
         extra_clauses.append(
             _build_status_clause(cols['BugTask._status'], params.status))
@@ -601,6 +606,8 @@
     if params.attachmenttype is not None:
         if params.attachmenttype == BugAttachmentType.PATCH:
             extra_clauses.append(Bug.latest_patch_uploaded != None)
+            if use_flat:
+                join_tables.append(flat_bug_join)
         else:
             extra_clauses.append(
                 cols['Bug.id'].is_in(
@@ -964,13 +971,7 @@
 
     # Translate orderby keys into corresponding Table.attribute
     # strings.
-    if use_flat:
-        extra_joins = [
-            (Bug, Join(Bug, Bug.id == BugTaskFlat.bug_id)),
-            (BugTask, Join(BugTask, BugTask.id == BugTaskFlat.bugtask_id)),
-            ]
-    else:
-        extra_joins = []
+    extra_joins = []
     ambiguous = True
     # Sorting by milestone only is a very "coarse" sort order.
     # If no additional sort order is specified, add the bug task