← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/drop-kick-getBugTasks into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #322129 in Launchpad itself: "Remove dsp.getBugTasks()"
  https://bugs.launchpad.net/launchpad/+bug/322129

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/drop-kick-getBugTasks/+merge/188490

Remove IDistributionSourcePackage.getBugTasks() and consign it to a watery grave.
-- 
https://code.launchpad.net/~stevenk/launchpad/drop-kick-getBugTasks/+merge/188490
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/drop-kick-getBugTasks into lp:launchpad.
=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
--- lib/lp/bugs/interfaces/bugtask.py	2013-03-12 06:50:10 +0000
+++ lib/lp/bugs/interfaces/bugtask.py	2013-10-01 01:03:16 +0000
@@ -850,12 +850,6 @@
         if the user doesn't have the permission to view this bug.
         """
 
-    def getBugTasks(bug_ids):
-        """Return the bugs with the given IDs and all of its bugtasks.
-
-        :return: A dictionary mapping the bugs to their bugtasks.
-        """
-
     def getBugTaskTags(bugtasks):
         """Return a set of bugtasks bug tags
 

=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py	2013-06-20 05:50:00 +0000
+++ lib/lp/bugs/model/bugtask.py	2013-10-01 01:03:16 +0000
@@ -1354,20 +1354,6 @@
                                 str(task_id))
         return bugtask
 
-    def getBugTasks(self, bug_ids):
-        """See `IBugTaskSet`."""
-        from lp.bugs.model.bug import Bug
-        store = IStore(Bug)
-        origin = [BugTask, Join(Bug, BugTask.bug == Bug.id)]
-        columns = (Bug, BugTask)
-        result = store.using(*origin).find(columns, Bug.id.is_in(bug_ids))
-        bugs_and_tasks = {}
-        for bug, task in result:
-            if bug not in bugs_and_tasks:
-                bugs_and_tasks[bug] = []
-            bugs_and_tasks[bug].append(task)
-        return bugs_and_tasks
-
     def getBugTaskTags(self, bugtasks):
         """See `IBugTaskSet`"""
         # Import locally to avoid circular imports.

=== modified file 'lib/lp/bugs/model/tests/test_bugtask.py'
--- lib/lp/bugs/model/tests/test_bugtask.py	2013-04-03 03:09:04 +0000
+++ lib/lp/bugs/model/tests/test_bugtask.py	2013-10-01 01:03:16 +0000
@@ -106,7 +106,6 @@
     TestCaseWithFactory,
     ws_object,
     )
-from lp.testing.factory import LaunchpadObjectFactory
 from lp.testing.fakemethod import FakeMethod
 from lp.testing.layers import (
     AppServerLayer,
@@ -1394,44 +1393,6 @@
             0, self.user, target=[])
 
 
-class BugTaskSetTest(unittest.TestCase):
-    """Test `BugTaskSet` methods."""
-    layer = DatabaseFunctionalLayer
-
-    def setUp(self):
-        login(ANONYMOUS)
-
-    def test_getBugTasks(self):
-        """ IBugTaskSet.getBugTasks() returns a dictionary mapping the given
-        bugs to their bugtasks. It does that in a single query, to avoid
-        hitting the DB again when getting the bugs' tasks.
-        """
-        login('no-priv@xxxxxxxxxxxxx')
-        factory = LaunchpadObjectFactory()
-        bug1 = factory.makeBug()
-        factory.makeBugTask(bug1)
-        bug2 = factory.makeBug()
-        factory.makeBugTask(bug2)
-        factory.makeBugTask(bug2)
-
-        bugs_and_tasks = getUtility(IBugTaskSet).getBugTasks(
-            [bug1.id, bug2.id])
-        # The bugtasks returned by getBugTasks() are exactly the same as the
-        # ones returned by bug.bugtasks, obviously.
-        self.failUnlessEqual(
-            set(bugs_and_tasks[bug1]).difference(bug1.bugtasks),
-            set([]))
-        self.failUnlessEqual(
-            set(bugs_and_tasks[bug2]).difference(bug2.bugtasks),
-            set([]))
-
-    def test_getBugTasks_with_empty_list(self):
-        # When given an empty list of bug IDs, getBugTasks() will return an
-        # empty dictionary.
-        bugs_and_tasks = getUtility(IBugTaskSet).getBugTasks([])
-        self.failUnlessEqual(bugs_and_tasks, {})
-
-
 class TestBugTaskStatuses(TestCase):
 
     def test_open_and_resolved_statuses(self):

=== modified file 'lib/lp/registry/interfaces/distributionsourcepackage.py'
--- lib/lp/registry/interfaces/distributionsourcepackage.py	2013-01-07 02:40:55 +0000
+++ lib/lp/registry/interfaces/distributionsourcepackage.py	2013-10-01 01:03:16 +0000
@@ -11,22 +11,14 @@
 
 from lazr.restful.declarations import (
     export_as_webservice_entry,
-    export_operation_as,
-    export_read_operation,
     exported,
-    operation_parameters,
-    operation_returns_collection_of,
-    rename_parameters_as,
     )
 from lazr.restful.fields import Reference
 from zope.interface import (
     Attribute,
     Interface,
     )
-from zope.schema import (
-    Int,
-    TextLine,
-    )
+from zope.schema import TextLine
 
 from lp import _
 from lp.answers.interfaces.questiontarget import IQuestionTarget
@@ -34,7 +26,6 @@
     IBugTarget,
     IHasOfficialBugTags,
     )
-from lp.bugs.interfaces.bugtask import IBugTask
 from lp.bugs.interfaces.structuralsubscription import (
     IStructuralSubscriptionTarget,
     )
@@ -181,21 +172,6 @@
         on how this criteria will be centrally encoded.
         """)
 
-    @rename_parameters_as(quantity='limit')
-    @operation_parameters(
-        quantity=Int(
-            title=_("The maximum number of bug tasks to return"),
-            min=1))
-    @operation_returns_collection_of(IBugTask)
-    @export_operation_as(name="getBugTasks")
-    @export_read_operation()
-    def bugtasks(quantity=None):
-        """Bug tasks on this source package, sorted newest first.
-
-        If needed, you can limit the number of bugtasks you are interested
-        in using the quantity parameter.
-        """
-
     def __eq__(other):
         """IDistributionSourcePackage comparison method.
 

=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
--- lib/lp/registry/model/distributionsourcepackage.py	2013-06-20 05:50:00 +0000
+++ lib/lp/registry/model/distributionsourcepackage.py	2013-10-01 01:03:16 +0000
@@ -278,16 +278,6 @@
             [self.sourcepackagename])
         return releases.get(self)
 
-    def bugtasks(self, quantity=None):
-        """See `IDistributionSourcePackage`."""
-        return BugTask.select("""
-            distribution=%s AND
-            sourcepackagename=%s
-            """ % sqlvalues(self.distribution.id,
-                            self.sourcepackagename.id),
-            orderBy='-datecreated',
-            limit=quantity)
-
     def get_distroseries_packages(self, active_only=True):
         """See `IDistributionSourcePackage`."""
         result = []

=== modified file 'lib/lp/registry/stories/webservice/xx-distribution-source-package.txt'
--- lib/lp/registry/stories/webservice/xx-distribution-source-package.txt	2011-03-23 16:28:51 +0000
+++ lib/lp/registry/stories/webservice/xx-distribution-source-package.txt	2013-10-01 01:03:16 +0000
@@ -1,4 +1,5 @@
-= Distribution Source Packages =
+Distribution Source Packages
+----------------------------
 
 Source packages can be obtained from the context of a distribution.
 
@@ -22,47 +23,6 @@
      u'upstream_product_link': None,
      u'web_link': u'http://launchpad.../debian/+source/mozilla-firefox'}
 
-You can obtain a collection of bug tasks associated with the source
-package using the "getBugTasks" method.
-
-    >>> bug_task_collection = webservice.named_get(
-    ...     mozilla_firefox['self_link'], 'getBugTasks').jsonBody()
-
-    >>> from operator import itemgetter
-    >>> def print_bug_tasks(bug_tasks):
-    ...     bug_tasks = sorted(bug_tasks, key=itemgetter('self_link'))
-    ...     for index, bug_task in enumerate(bug_tasks):
-    ...         print '%d. %s' % (index, bug_task['title'])
-    ...         print '   %s, %s, <%s>' % (
-    ...             bug_task['status'], bug_task['importance'],
-    ...             bug_task['bug_link'])
-    ...         print '   <%s>' % (bug_task['self_link'],)
-
-    >>> print_bug_tasks(bug_task_collection['entries'])
-    0. Bug #1 in mozilla-firefox (Debian): "Firefox does not support SVG"
-       Confirmed, Low, <http://api.launchpad.dev/beta/bugs/1>
-       <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/1>
-    1. Bug #2 in mozilla-firefox (Debian): "Blackhole Trash folder"
-       Confirmed, Low, <http://api.launchpad.dev/beta/bugs/2>
-       <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/2>
-    2. Bug #3 in mozilla-firefox (Debian): "Bug Title Test"
-       New, Unknown, <http://api.launchpad.dev/beta/bugs/3>
-       <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/3>
-    3. Bug #8 in mozilla-firefox (Debian): "Printing doesn't work"
-       Fix Released, Medium, <http://api.launchpad.dev/beta/bugs/8>
-       <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/8>
-
-A number can be passed to limit the number of bug tasks returned:
-
-    >>> bug_task_collection = webservice.named_get(
-    ...     mozilla_firefox['self_link'],
-    ...     'getBugTasks', limit=1).jsonBody()
-
-    >>> print_bug_tasks(bug_task_collection['entries'])
-    0. Bug #8 in mozilla-firefox (Debian): "Printing doesn't work"
-       Fix Released, Medium, <http://api.launchpad.dev/beta/bugs/8>
-       <http://api.launchpad.dev/beta/debian/+source/mozilla-firefox/+bug/8>
-
 It's also possible to search for tasks with the "searchTasks" method:
 
     >>> bug_task_collection = webservice.named_get(


Follow ups