← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-1028279 into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-1028279 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1028279 in Launchpad itself: "bugsummaryrebuild uses BugSubscriptions instead of AccessArtifactGrants"
  https://bugs.launchpad.net/launchpad/+bug/1028279

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1028279/+merge/116411

The BugSummary maintenance triggers now use BugTaskFlat.access_grants instead of BugSubscription, so BugSummaryRebuild should too. These matched until we removed the legacy triggers a couple of weeks back, but have since diverged.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-1028279/+merge/116411
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1028279 into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugtaskflat.py'
--- lib/lp/bugs/model/bugtaskflat.py	2012-06-14 05:18:22 +0000
+++ lib/lp/bugs/model/bugtaskflat.py	2012-07-24 07:32:21 +0000
@@ -7,6 +7,7 @@
     Bool,
     DateTime,
     Int,
+    List,
     Reference,
     Storm,
     )
@@ -58,3 +59,5 @@
     owner_id = Int(name='owner')
     owner = Reference(owner_id, 'Person.id')
     active = Bool()
+    access_grants = List(type=Int())
+    access_policies = List(type=Int())

=== modified file 'lib/lp/bugs/scripts/bugsummaryrebuild.py'
--- lib/lp/bugs/scripts/bugsummaryrebuild.py	2012-07-12 01:25:25 +0000
+++ lib/lp/bugs/scripts/bugsummaryrebuild.py	2012-07-24 07:32:21 +0000
@@ -18,7 +18,6 @@
 import transaction
 
 from lp.bugs.model.bug import BugTag
-from lp.bugs.model.bugsubscription import BugSubscription
 from lp.bugs.model.bugsummary import BugSummary
 from lp.bugs.model.bugtask import (
     bug_target_from_key,
@@ -40,6 +39,7 @@
 from lp.registry.model.sourcepackagename import SourcePackageName
 from lp.services.database.bulk import create
 from lp.services.database.lpstorm import IStore
+from lp.services.database.stormexpr import Unnest
 from lp.services.looptuner import TunableLoop
 
 
@@ -252,7 +252,8 @@
             (BugTaskFlat.bug_id, BugTaskFlat.information_type,
              BugTaskFlat.status, BugTaskFlat.milestone_id,
              BugTaskFlat.importance,
-             Alias(BugTaskFlat.latest_patch_uploaded != None, 'has_patch')),
+             Alias(BugTaskFlat.latest_patch_uploaded != None, 'has_patch'),
+             BugTaskFlat.access_grants),
             tables=[BugTaskFlat],
             where=And(
                 BugTaskFlat.duplicateof_id == None,
@@ -278,9 +279,6 @@
     null_viewed_by = Alias(Cast(None, 'integer'), 'viewed_by')
 
     tag_join = Join(BugTag, BugTag.bugID == RelevantTask.bug_id)
-    sub_join = Join(
-        BugSubscription,
-        BugSubscription.bug_id == RelevantTask.bug_id)
 
     public_constraint = RelevantTask.information_type.is_in(
         PUBLIC_INFORMATION_TYPES)
@@ -298,13 +296,12 @@
             tables=[RelevantTask, tag_join], where=public_constraint),
         # Private, tagless
         Select(
-            common_cols + (null_tag, BugSubscription.person_id),
-            tables=[RelevantTask, sub_join], where=private_constraint),
+            common_cols + (null_tag, Unnest(RelevantTask.access_grants)),
+            tables=[RelevantTask], where=private_constraint),
         # Private, tagged
         Select(
-            common_cols + (BugTag.tag, BugSubscription.person_id),
-            tables=[RelevantTask, sub_join, tag_join],
-            where=private_constraint),
+            common_cols + (BugTag.tag, Unnest(RelevantTask.access_grants)),
+            tables=[RelevantTask, tag_join], where=private_constraint),
         all=True)
 
     # Select the relevant bits of the prototype rows and aggregate them.

=== modified file 'lib/lp/services/database/stormexpr.py'
--- lib/lp/services/database/stormexpr.py	2012-07-19 03:18:37 +0000
+++ lib/lp/services/database/stormexpr.py	2012-07-24 07:32:21 +0000
@@ -15,6 +15,7 @@
     'get_where_for_reference',
     'NullCount',
     'TryAdvisoryLock',
+    'Unnest',
     ]
 
 from storm.exceptions import ClassInfoError
@@ -117,19 +118,25 @@
 
 
 class ArrayAgg(NamedFunc):
-    "Aggregate values (within a GROUP BY) into an array."
+    """Aggregate values (within a GROUP BY) into an array."""
     __slots__ = ()
     name = "ARRAY_AGG"
 
 
+class Unnest(NamedFunc):
+    """Expand an array to a set of rows."""
+    __slots__ = ()
+    name = "unnest"
+
+
 class ArrayContains(CompoundOper):
-    "True iff the left side is a superset of the right side."
+    """True iff the left side is a superset of the right side."""
     __slots__ = ()
     oper = "@>"
 
 
 class ArrayIntersects(CompoundOper):
-    "True iff the left side shares at least one element with the right side."
+    """True iff the arrays have at least one element in common."""
     __slots__ = ()
     oper = "&&"
 


Follow ups