Merge lp:~stevenk/launchpad/drop-kick-getBugTasks into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 16783
Proposed branch: lp:~stevenk/launchpad/drop-kick-getBugTasks
Merge into: lp:launchpad
Diff against target: 236 lines (+3/-136)
6 files modified
lib/lp/bugs/interfaces/bugtask.py (+0/-6)
lib/lp/bugs/model/bugtask.py (+0/-14)
lib/lp/bugs/model/tests/test_bugtask.py (+0/-39)
lib/lp/registry/interfaces/distributionsourcepackage.py (+1/-25)
lib/lp/registry/model/distributionsourcepackage.py (+0/-10)
lib/lp/registry/stories/webservice/xx-distribution-source-package.txt (+2/-42)
To merge this branch: bzr merge lp:~stevenk/launchpad/drop-kick-getBugTasks
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+188490@code.launchpad.net

Commit message

Remove IDistributionSourcePackage.getBugTasks() and consign it to a watery grave.

Description of the change

Remove IDistributionSourcePackage.getBugTasks() and consign it to a watery grave.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
2--- lib/lp/bugs/interfaces/bugtask.py 2013-03-12 06:50:10 +0000
3+++ lib/lp/bugs/interfaces/bugtask.py 2013-10-01 01:03:16 +0000
4@@ -850,12 +850,6 @@
5 if the user doesn't have the permission to view this bug.
6 """
7
8- def getBugTasks(bug_ids):
9- """Return the bugs with the given IDs and all of its bugtasks.
10-
11- :return: A dictionary mapping the bugs to their bugtasks.
12- """
13-
14 def getBugTaskTags(bugtasks):
15 """Return a set of bugtasks bug tags
16
17
18=== modified file 'lib/lp/bugs/model/bugtask.py'
19--- lib/lp/bugs/model/bugtask.py 2013-06-20 05:50:00 +0000
20+++ lib/lp/bugs/model/bugtask.py 2013-10-01 01:03:16 +0000
21@@ -1354,20 +1354,6 @@
22 str(task_id))
23 return bugtask
24
25- def getBugTasks(self, bug_ids):
26- """See `IBugTaskSet`."""
27- from lp.bugs.model.bug import Bug
28- store = IStore(Bug)
29- origin = [BugTask, Join(Bug, BugTask.bug == Bug.id)]
30- columns = (Bug, BugTask)
31- result = store.using(*origin).find(columns, Bug.id.is_in(bug_ids))
32- bugs_and_tasks = {}
33- for bug, task in result:
34- if bug not in bugs_and_tasks:
35- bugs_and_tasks[bug] = []
36- bugs_and_tasks[bug].append(task)
37- return bugs_and_tasks
38-
39 def getBugTaskTags(self, bugtasks):
40 """See `IBugTaskSet`"""
41 # Import locally to avoid circular imports.
42
43=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
44--- lib/lp/bugs/model/tests/test_bugtask.py 2013-04-03 03:09:04 +0000
45+++ lib/lp/bugs/model/tests/test_bugtask.py 2013-10-01 01:03:16 +0000
46@@ -106,7 +106,6 @@
47 TestCaseWithFactory,
48 ws_object,
49 )
50-from lp.testing.factory import LaunchpadObjectFactory
51 from lp.testing.fakemethod import FakeMethod
52 from lp.testing.layers import (
53 AppServerLayer,
54@@ -1394,44 +1393,6 @@
55 0, self.user, target=[])
56
57
58-class BugTaskSetTest(unittest.TestCase):
59- """Test `BugTaskSet` methods."""
60- layer = DatabaseFunctionalLayer
61-
62- def setUp(self):
63- login(ANONYMOUS)
64-
65- def test_getBugTasks(self):
66- """ IBugTaskSet.getBugTasks() returns a dictionary mapping the given
67- bugs to their bugtasks. It does that in a single query, to avoid
68- hitting the DB again when getting the bugs' tasks.
69- """
70- login('no-priv@canonical.com')
71- factory = LaunchpadObjectFactory()
72- bug1 = factory.makeBug()
73- factory.makeBugTask(bug1)
74- bug2 = factory.makeBug()
75- factory.makeBugTask(bug2)
76- factory.makeBugTask(bug2)
77-
78- bugs_and_tasks = getUtility(IBugTaskSet).getBugTasks(
79- [bug1.id, bug2.id])
80- # The bugtasks returned by getBugTasks() are exactly the same as the
81- # ones returned by bug.bugtasks, obviously.
82- self.failUnlessEqual(
83- set(bugs_and_tasks[bug1]).difference(bug1.bugtasks),
84- set([]))
85- self.failUnlessEqual(
86- set(bugs_and_tasks[bug2]).difference(bug2.bugtasks),
87- set([]))
88-
89- def test_getBugTasks_with_empty_list(self):
90- # When given an empty list of bug IDs, getBugTasks() will return an
91- # empty dictionary.
92- bugs_and_tasks = getUtility(IBugTaskSet).getBugTasks([])
93- self.failUnlessEqual(bugs_and_tasks, {})
94-
95-
96 class TestBugTaskStatuses(TestCase):
97
98 def test_open_and_resolved_statuses(self):
99
100=== modified file 'lib/lp/registry/interfaces/distributionsourcepackage.py'
101--- lib/lp/registry/interfaces/distributionsourcepackage.py 2013-01-07 02:40:55 +0000
102+++ lib/lp/registry/interfaces/distributionsourcepackage.py 2013-10-01 01:03:16 +0000
103@@ -11,22 +11,14 @@
104
105 from lazr.restful.declarations import (
106 export_as_webservice_entry,
107- export_operation_as,
108- export_read_operation,
109 exported,
110- operation_parameters,
111- operation_returns_collection_of,
112- rename_parameters_as,
113 )
114 from lazr.restful.fields import Reference
115 from zope.interface import (
116 Attribute,
117 Interface,
118 )
119-from zope.schema import (
120- Int,
121- TextLine,
122- )
123+from zope.schema import TextLine
124
125 from lp import _
126 from lp.answers.interfaces.questiontarget import IQuestionTarget
127@@ -34,7 +26,6 @@
128 IBugTarget,
129 IHasOfficialBugTags,
130 )
131-from lp.bugs.interfaces.bugtask import IBugTask
132 from lp.bugs.interfaces.structuralsubscription import (
133 IStructuralSubscriptionTarget,
134 )
135@@ -181,21 +172,6 @@
136 on how this criteria will be centrally encoded.
137 """)
138
139- @rename_parameters_as(quantity='limit')
140- @operation_parameters(
141- quantity=Int(
142- title=_("The maximum number of bug tasks to return"),
143- min=1))
144- @operation_returns_collection_of(IBugTask)
145- @export_operation_as(name="getBugTasks")
146- @export_read_operation()
147- def bugtasks(quantity=None):
148- """Bug tasks on this source package, sorted newest first.
149-
150- If needed, you can limit the number of bugtasks you are interested
151- in using the quantity parameter.
152- """
153-
154 def __eq__(other):
155 """IDistributionSourcePackage comparison method.
156
157
158=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
159--- lib/lp/registry/model/distributionsourcepackage.py 2013-06-20 05:50:00 +0000
160+++ lib/lp/registry/model/distributionsourcepackage.py 2013-10-01 01:03:16 +0000
161@@ -278,16 +278,6 @@
162 [self.sourcepackagename])
163 return releases.get(self)
164
165- def bugtasks(self, quantity=None):
166- """See `IDistributionSourcePackage`."""
167- return BugTask.select("""
168- distribution=%s AND
169- sourcepackagename=%s
170- """ % sqlvalues(self.distribution.id,
171- self.sourcepackagename.id),
172- orderBy='-datecreated',
173- limit=quantity)
174-
175 def get_distroseries_packages(self, active_only=True):
176 """See `IDistributionSourcePackage`."""
177 result = []
178
179=== modified file 'lib/lp/registry/stories/webservice/xx-distribution-source-package.txt'
180--- lib/lp/registry/stories/webservice/xx-distribution-source-package.txt 2011-03-23 16:28:51 +0000
181+++ lib/lp/registry/stories/webservice/xx-distribution-source-package.txt 2013-10-01 01:03:16 +0000
182@@ -1,4 +1,5 @@
183-= Distribution Source Packages =
184+Distribution Source Packages
185+----------------------------
186
187 Source packages can be obtained from the context of a distribution.
188
189@@ -22,47 +23,6 @@
190 u'upstream_product_link': None,
191 u'web_link': u'http://launchpad.../debian/+source/mozilla-firefox'}
192
193-You can obtain a collection of bug tasks associated with the source
194-package using the "getBugTasks" method.
195-
196- >>> bug_task_collection = webservice.named_get(
197- ... mozilla_firefox['self_link'], 'getBugTasks').jsonBody()
198-
199- >>> from operator import itemgetter
200- >>> def print_bug_tasks(bug_tasks):
201- ... bug_tasks = sorted(bug_tasks, key=itemgetter('self_link'))
202- ... for index, bug_task in enumerate(bug_tasks):
203- ... print '%d. %s' % (index, bug_task['title'])
204- ... print ' %s, %s, <%s>' % (
205- ... bug_task['status'], bug_task['importance'],
206- ... bug_task['bug_link'])
207- ... print ' <%s>' % (bug_task['self_link'],)
208-
209- >>> print_bug_tasks(bug_task_collection['entries'])
210- 0. Bug #1 in mozilla-firefox (Debian): "Firefox does not support SVG"
211- Confirmed, Low, <http://api.launchpad.dev/beta/bugs/1>
212- <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/1>
213- 1. Bug #2 in mozilla-firefox (Debian): "Blackhole Trash folder"
214- Confirmed, Low, <http://api.launchpad.dev/beta/bugs/2>
215- <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/2>
216- 2. Bug #3 in mozilla-firefox (Debian): "Bug Title Test"
217- New, Unknown, <http://api.launchpad.dev/beta/bugs/3>
218- <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/3>
219- 3. Bug #8 in mozilla-firefox (Debian): "Printing doesn't work"
220- Fix Released, Medium, <http://api.launchpad.dev/beta/bugs/8>
221- <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/8>
222-
223-A number can be passed to limit the number of bug tasks returned:
224-
225- >>> bug_task_collection = webservice.named_get(
226- ... mozilla_firefox['self_link'],
227- ... 'getBugTasks', limit=1).jsonBody()
228-
229- >>> print_bug_tasks(bug_task_collection['entries'])
230- 0. Bug #8 in mozilla-firefox (Debian): "Printing doesn't work"
231- Fix Released, Medium, <http://api.launchpad.dev/beta/bugs/8>
232- <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/8>
233-
234 It's also possible to search for tasks with the "searchTasks" method:
235
236 >>> bug_task_collection = webservice.named_get(