launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08850
[Merge] lp:~brian-murray/launchpad/bug-826854 into lp:launchpad
Brian Murray has proposed merging lp:~brian-murray/launchpad/bug-826854 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #826854 in Launchpad itself: "It should be possible to search bugs given a range of date_created using the API"
https://bugs.launchpad.net/launchpad/+bug/826854
For more details, see:
https://code.launchpad.net/~brian-murray/launchpad/bug-826854/+merge/110428
This branch adds a created_before parameter to searchTasks so that bug tasks created before 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_search.py
bin/test -cvvt xx-bug.txt -t test_created_before
--
https://code.launchpad.net/~brian-murray/launchpad/bug-826854/+merge/110428
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~brian-murray/launchpad/bug-826854 into lp:launchpad.
=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
--- lib/lp/bugs/interfaces/bugtarget.py 2012-04-17 08:01:35 +0000
+++ lib/lp/bugs/interfaces/bugtarget.py 2012-06-14 21:58:25 +0000
@@ -173,6 +173,11 @@
u"Search for bugs that have been created since the given "
"date."),
required=False),
+ "created_before": Datetime(
+ title=_(
+ u"Search for bugs that were created before the given "
+ "date."),
+ required=False),
}
search_tasks_params_for_api_default = dict(
@@ -252,7 +257,8 @@
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False, linked_branches=None,
linked_blueprints=None, structural_subscriber=None,
- modified_since=None, created_since=None):
+ modified_since=None, created_since=None,
+ created_before=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 2012-05-22 12:05:51 +0000
+++ lib/lp/bugs/interfaces/bugtask.py 2012-06-14 21:58:25 +0000
@@ -1178,7 +1178,7 @@
structural_subscriber=None, modified_since=None,
created_since=None, exclude_conjoined_tasks=False, cve=None,
upstream_target=None, milestone_dateexpected_before=None,
- milestone_dateexpected_after=None):
+ milestone_dateexpected_after=None, created_before=None):
self.bug = bug
self.searchtext = searchtext
@@ -1226,6 +1226,7 @@
self.structural_subscriber = structural_subscriber
self.modified_since = modified_since
self.created_since = created_since
+ self.created_before = created_before
self.exclude_conjoined_tasks = exclude_conjoined_tasks
self.cve = cve
self.upstream_target = upstream_target
@@ -1375,7 +1376,8 @@
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False, linked_branches=None,
linked_blueprints=None, structural_subscriber=None,
- modified_since=None, created_since=None):
+ modified_since=None, created_since=None,
+ created_before=None):
"""Create and return a new instance using the parameter list."""
search_params = cls(user=user, orderby=order_by)
@@ -1446,6 +1448,7 @@
search_params.structural_subscriber = structural_subscriber
search_params.modified_since = modified_since
search_params.created_since = created_since
+ search_params.created_before = created_before
return search_params
=== modified file 'lib/lp/bugs/model/bugtarget.py'
--- lib/lp/bugs/model/bugtarget.py 2012-04-17 08:01:35 +0000
+++ lib/lp/bugs/model/bugtarget.py 2012-06-14 21:58:25 +0000
@@ -81,7 +81,7 @@
hardware_owner_is_subscribed_to_bug=False,
hardware_is_linked_to_bug=False, linked_branches=None,
linked_blueprints=None, modified_since=None,
- created_since=None):
+ created_since=None, created_before=None):
"""See `IHasBugs`."""
if status is None:
# If no statuses are supplied, default to the
=== modified file 'lib/lp/bugs/model/bugtasksearch.py'
--- lib/lp/bugs/model/bugtasksearch.py 2012-05-24 22:25:01 +0000
+++ lib/lp/bugs/model/bugtasksearch.py 2012-06-14 21:58:25 +0000
@@ -723,6 +723,10 @@
extra_clauses.append(
BugTaskFlat.datecreated > params.created_since)
+ if params.created_before:
+ extra_clauses.append(
+ BugTaskFlat.datecreated < params.created_before)
+
query = And(extra_clauses)
if not decorators:
=== modified file 'lib/lp/bugs/stories/webservice/xx-bug.txt'
--- lib/lp/bugs/stories/webservice/xx-bug.txt 2012-04-26 23:20:48 +0000
+++ lib/lp/bugs/stories/webservice/xx-bug.txt 2012-06-14 21:58:25 +0000
@@ -1482,6 +1482,17 @@
...
---
+Or for finding bug tasks created before a certain date.
+
+ >>> before_date = task.datecreated + timedelta(days=8)
+ >>> pprint_collection(webservice.named_get(
+ ... '/%s' % target.name, 'searchTasks',
+ ... created_before=u'%s' % before_date).jsonBody())
+ start: 0
+ total_size: 1
+ ...
+ ---
+
It is possible to search for bugs targeted to a milestone within a
project group.
=== modified file 'lib/lp/bugs/tests/test_bugtask_search.py'
--- lib/lp/bugs/tests/test_bugtask_search.py 2012-05-02 03:40:06 +0000
+++ lib/lp/bugs/tests/test_bugtask_search.py 2012-06-14 21:58:25 +0000
@@ -323,6 +323,17 @@
user=None, created_since=one_day_ago)
self.assertSearchFinds(params, self.bugtasks[1:])
+ def test_created_before(self):
+ # Search results can be limited to bugtasks created before a
+ # given time.
+ one_day_ago = self.bugtasks[0].datecreated - timedelta(days=1)
+ two_days_ago = self.bugtasks[0].datecreated - timedelta(days=2)
+ with person_logged_in(self.owner):
+ self.bugtasks[0].datecreated = two_days_ago
+ params = self.getBugTaskSearchParams(
+ user=None, created_before=one_day_ago)
+ self.assertSearchFinds(params, self.bugtasks[0:1])
+
def test_modified_since(self):
# Search results can be limited to bugs modified after a
# given time.
Follow ups