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

Proposed by William Grant on 2012-07-24
Status: Merged
Merged at revision: 15679
Proposed branch: lp:~wgrant/launchpad/bug-1028279
Merge into: lp:launchpad
Diff against target: 115 lines (+20/-13)
3 files modified
lib/lp/bugs/model/bugtaskflat.py (+3/-0)
lib/lp/bugs/scripts/bugsummaryrebuild.py (+7/-10)
lib/lp/services/database/stormexpr.py (+10/-3)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-1028279
Reviewer Review Type Date Requested Status
Richard Harding (community) 2012-07-24 Approve on 2012-07-24
Review via email: mp+116411@code.launchpad.net

Commit Message

BugSummaryRebuild now uses BugTaskFlat.access_grants rather than joining BugSubscription.

Description of the Change

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.

To post a comment you must log in.
Richard Harding (rharding) :
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/bugtaskflat.py'
2--- lib/lp/bugs/model/bugtaskflat.py 2012-06-14 05:18:22 +0000
3+++ lib/lp/bugs/model/bugtaskflat.py 2012-07-24 07:32:21 +0000
4@@ -7,6 +7,7 @@
5 Bool,
6 DateTime,
7 Int,
8+ List,
9 Reference,
10 Storm,
11 )
12@@ -58,3 +59,5 @@
13 owner_id = Int(name='owner')
14 owner = Reference(owner_id, 'Person.id')
15 active = Bool()
16+ access_grants = List(type=Int())
17+ access_policies = List(type=Int())
18
19=== modified file 'lib/lp/bugs/scripts/bugsummaryrebuild.py'
20--- lib/lp/bugs/scripts/bugsummaryrebuild.py 2012-07-12 01:25:25 +0000
21+++ lib/lp/bugs/scripts/bugsummaryrebuild.py 2012-07-24 07:32:21 +0000
22@@ -18,7 +18,6 @@
23 import transaction
24
25 from lp.bugs.model.bug import BugTag
26-from lp.bugs.model.bugsubscription import BugSubscription
27 from lp.bugs.model.bugsummary import BugSummary
28 from lp.bugs.model.bugtask import (
29 bug_target_from_key,
30@@ -40,6 +39,7 @@
31 from lp.registry.model.sourcepackagename import SourcePackageName
32 from lp.services.database.bulk import create
33 from lp.services.database.lpstorm import IStore
34+from lp.services.database.stormexpr import Unnest
35 from lp.services.looptuner import TunableLoop
36
37
38@@ -252,7 +252,8 @@
39 (BugTaskFlat.bug_id, BugTaskFlat.information_type,
40 BugTaskFlat.status, BugTaskFlat.milestone_id,
41 BugTaskFlat.importance,
42- Alias(BugTaskFlat.latest_patch_uploaded != None, 'has_patch')),
43+ Alias(BugTaskFlat.latest_patch_uploaded != None, 'has_patch'),
44+ BugTaskFlat.access_grants),
45 tables=[BugTaskFlat],
46 where=And(
47 BugTaskFlat.duplicateof_id == None,
48@@ -278,9 +279,6 @@
49 null_viewed_by = Alias(Cast(None, 'integer'), 'viewed_by')
50
51 tag_join = Join(BugTag, BugTag.bugID == RelevantTask.bug_id)
52- sub_join = Join(
53- BugSubscription,
54- BugSubscription.bug_id == RelevantTask.bug_id)
55
56 public_constraint = RelevantTask.information_type.is_in(
57 PUBLIC_INFORMATION_TYPES)
58@@ -298,13 +296,12 @@
59 tables=[RelevantTask, tag_join], where=public_constraint),
60 # Private, tagless
61 Select(
62- common_cols + (null_tag, BugSubscription.person_id),
63- tables=[RelevantTask, sub_join], where=private_constraint),
64+ common_cols + (null_tag, Unnest(RelevantTask.access_grants)),
65+ tables=[RelevantTask], where=private_constraint),
66 # Private, tagged
67 Select(
68- common_cols + (BugTag.tag, BugSubscription.person_id),
69- tables=[RelevantTask, sub_join, tag_join],
70- where=private_constraint),
71+ common_cols + (BugTag.tag, Unnest(RelevantTask.access_grants)),
72+ tables=[RelevantTask, tag_join], where=private_constraint),
73 all=True)
74
75 # Select the relevant bits of the prototype rows and aggregate them.
76
77=== modified file 'lib/lp/services/database/stormexpr.py'
78--- lib/lp/services/database/stormexpr.py 2012-07-19 03:18:37 +0000
79+++ lib/lp/services/database/stormexpr.py 2012-07-24 07:32:21 +0000
80@@ -15,6 +15,7 @@
81 'get_where_for_reference',
82 'NullCount',
83 'TryAdvisoryLock',
84+ 'Unnest',
85 ]
86
87 from storm.exceptions import ClassInfoError
88@@ -117,19 +118,25 @@
89
90
91 class ArrayAgg(NamedFunc):
92- "Aggregate values (within a GROUP BY) into an array."
93+ """Aggregate values (within a GROUP BY) into an array."""
94 __slots__ = ()
95 name = "ARRAY_AGG"
96
97
98+class Unnest(NamedFunc):
99+ """Expand an array to a set of rows."""
100+ __slots__ = ()
101+ name = "unnest"
102+
103+
104 class ArrayContains(CompoundOper):
105- "True iff the left side is a superset of the right side."
106+ """True iff the left side is a superset of the right side."""
107 __slots__ = ()
108 oper = "@>"
109
110
111 class ArrayIntersects(CompoundOper):
112- "True iff the left side shares at least one element with the right side."
113+ """True iff the arrays have at least one element in common."""
114 __slots__ = ()
115 oper = "&&"
116