launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01651
[Merge] lp:~brian-murray/launchpad/search-tasks-by-date-created into lp:launchpad/devel
Brian Murray has proposed merging lp:~brian-murray/launchpad/search-tasks-by-date-created into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#327688 It should be possible to search bugs given a range of date_created using the API
https://bugs.launchpad.net/bugs/327688
This branch adds a created_since parameter to searchTasks so that bug tasks created after a specific date can be searched for using the API. As tasks are being searched and used we are looking at bugtask.datecreated instead of bug.datecreated.
Tests have been added to webservice/xx-bug.txt and test_bugtask.py.
bin/test -cvvt xx-bug.txt -t lp.bugs.tests.test_bugtask.TestBugTaskSearch.test_created_since
--
https://code.launchpad.net/~brian-murray/launchpad/search-tasks-by-date-created/+merge/39066
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~brian-murray/launchpad/search-tasks-by-date-created into lp:launchpad/devel.
=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
--- lib/lp/bugs/interfaces/bugtarget.py 2010-09-22 08:48:24 +0000
+++ lib/lp/bugs/interfaces/bugtarget.py 2010-10-21 16:51:25 +0000
@@ -165,6 +165,11 @@
u"Search for bugs that have been modified since the given "
"date."),
required=False),
+ "created_since": Datetime(
+ title=_(
+ u"Search for bugs that have been created since the given "
+ "date."),
+ required=False),
}
search_tasks_params_for_api_devel = search_tasks_params_for_api_1_0.copy()
search_tasks_params_for_api_devel["omit_targeted"] = copy_field(
@@ -226,7 +231,8 @@
hardware_owner_is_affected_by_bug=False,
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False, linked_branches=None,
- structural_subscriber=None, modified_since=None):
+ structural_subscriber=None, modified_since=None,
+ created_since=None):
"""Search the IBugTasks reported on this entity.
:search_params: a BugTaskSearchParams object
=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
--- lib/lp/bugs/interfaces/bugtask.py 2010-09-21 09:37:06 +0000
+++ lib/lp/bugs/interfaces/bugtask.py 2010-10-21 16:51:25 +0000
@@ -1143,7 +1143,7 @@
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False,
linked_branches=None, structural_subscriber=None,
- modified_since=None):
+ modified_since=None, created_since=None):
self.bug = bug
self.searchtext = searchtext
@@ -1189,6 +1189,7 @@
self.linked_branches = linked_branches
self.structural_subscriber = structural_subscriber
self.modified_since = None
+ self.created_since = None
def setProduct(self, product):
"""Set the upstream context on which to filter the search."""
@@ -1261,7 +1262,8 @@
hardware_owner_is_affected_by_bug=False,
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False, linked_branches=None,
- structural_subscriber=None, modified_since=None):
+ structural_subscriber=None, modified_since=None,
+ created_since=None):
"""Create and return a new instance using the parameter list."""
search_params = cls(user=user, orderby=order_by)
@@ -1331,6 +1333,7 @@
search_params.linked_branches=linked_branches
search_params.structural_subscriber = structural_subscriber
search_params.modified_since = modified_since
+ search_params.created_since = created_since
return search_params
=== modified file 'lib/lp/bugs/model/bugtarget.py'
--- lib/lp/bugs/model/bugtarget.py 2010-10-14 15:22:46 +0000
+++ lib/lp/bugs/model/bugtarget.py 2010-10-21 16:51:25 +0000
@@ -93,7 +93,7 @@
hardware_owner_is_affected_by_bug=False,
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False, linked_branches=None,
- modified_since=None):
+ modified_since=None, created_since=None):
"""See `IHasBugs`."""
if status is None:
# If no statuses are supplied, default to the
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2010-09-23 10:27:11 +0000
+++ lib/lp/bugs/model/bugtask.py 2010-10-21 16:51:25 +0000
@@ -1942,6 +1942,11 @@
"Bug.date_last_updated > %s" % (
sqlvalues(params.modified_since,)))
+ if params.created_since:
+ extra_clauses.append(
+ "BugTask.datecreated > %s" % (
+ sqlvalues(params.created_since,)))
+
orderby_arg = self._processOrderBy(params)
query = " AND ".join(extra_clauses)
=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
--- lib/lp/bugs/stories/webservice/xx-bug.txt 2010-10-21 01:42:14 +0000
+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2010-10-21 16:51:25 +0000
@@ -1493,6 +1493,15 @@
total_size: 0
---
+It can also be used to find bug tasks created since a certain date.
+
+ >>> pprint_collection(webservice.named_get(
+ ... '/ubuntu', 'searchTasks',
+ ... created_since=u'2012-01-01T00:00:00+00:00').jsonBody())
+ start: 0
+ total_size: 0
+ ---
+
It is possible to search for bugs targeted to a milestone within a
project group.
=== modified file 'lib/lp/bugs/tests/test_bugtask.py'
--- lib/lp/bugs/tests/test_bugtask.py 2010-10-04 19:50:45 +0000
+++ lib/lp/bugs/tests/test_bugtask.py 2010-10-21 16:51:25 +0000
@@ -908,6 +908,42 @@
default_result = target.searchTasks(None)
self.assertEqual([task1], list(default_result))
+ def test_created_since_excludes_earlier_bugtasks(self):
+ # When we search for bug tasks that have been created since a certain
+ # time, tasks for bugs that have not been created since then are
+ # excluded.
+ target = self.makeBugTarget()
+ self.login()
+ task = self.factory.makeBugTask(target=target)
+ date = task.datecreated + timedelta(days=1)
+ result = target.searchTasks(None, created_since=date)
+ self.assertEqual([], list(result))
+
+ def test_created_since_includes_later_bugtasks(self):
+ # When we search for bug tasks that have been created since a certain
+ # time, tasks for bugs that have been created since then are
+ # included.
+ target = self.makeBugTarget()
+ self.login()
+ task = self.factory.makeBugTask(target=target)
+ date = task.datecreated - timedelta(days=1)
+ result = target.searchTasks(None, created_since=date)
+ self.assertEqual([task], list(result))
+
+ def test_created_since_includes_later_bugtasks_excludes_earlier(self):
+ # When we search for bugs that have been created since a certain
+ # time, tasks for bugs that have been created since then are
+ # included, tasks that have not are excluded.
+ target = self.makeBugTarget()
+ self.login()
+ task1 = self.factory.makeBugTask(target=target)
+ date = task1.datecreated
+ task1.datecreated -= timedelta(days=1)
+ task2 = self.factory.makeBugTask(target=target)
+ task2.datecreated += timedelta(days=1)
+ result = target.searchTasks(None, created_since=date)
+ self.assertEqual([task2], list(result))
+
def test_suite():
suite = unittest.TestSuite()