launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07143
[Merge] lp:~wgrant/launchpad/bugtaskflat-search--1 into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/bugtaskflat-search--1 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bugtaskflat-search--1/+merge/102416
This branch comprises a little more preparation for BugTaskFlat searching. search_bugs() takes an argument to use as the Storm findspec, but it's always either BugTask or BugTask.bugID. I've changed it to instead accept a just_bug_ids boolean argument, which will make the BugTaskFlat searching implementation slightly less hideous.
--
https://code.launchpad.net/~wgrant/launchpad/bugtaskflat-search--1/+merge/102416
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bugtaskflat-search--1 into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2012-04-17 08:47:32 +0000
+++ lib/lp/bugs/model/bugtask.py 2012-04-18 01:49:18 +0000
@@ -1518,12 +1518,12 @@
load_related(Bug, rows, ['bugID'])
load_related(Product, rows, ['productID'])
load_related(SourcePackageName, rows, ['sourcepackagenameID'])
- return search_bugs(BugTask, eager_load, (params,) + args)
+ return search_bugs(eager_load, (params,) + args)
def searchBugIds(self, params):
"""See `IBugTaskSet`."""
from lp.bugs.model.bugtasksearch import search_bugs
- return search_bugs(BugTask.bugID, None, [params]).result_set
+ return search_bugs(None, [params], just_bug_ids=True).result_set
def countBugs(self, user, contexts, group_on):
"""See `IBugTaskSet`."""
=== modified file 'lib/lp/bugs/model/bugtasksearch.py'
--- lib/lp/bugs/model/bugtasksearch.py 2012-04-17 22:34:31 +0000
+++ lib/lp/bugs/model/bugtasksearch.py 2012-04-18 01:49:18 +0000
@@ -200,20 +200,22 @@
return comp == None
-def search_bugs(resultrow, pre_iter_hook, alternatives):
- """Return a Storm result set for the given search parameters.
+def search_bugs(pre_iter_hook, alternatives, just_bug_ids=False):
+ """Return a ResultSet of BugTasks for the given search parameters.
- :param resultrow: The type of data returned by the query.
:param pre_iter_hook: An optional pre-iteration hook used for eager
loading bug targets for list views.
:param alternatives: A sequence of BugTaskSearchParams instances, the
results of which will be unioned. Only the first ordering is
respected.
+ :param just_bug_ids: Return a ResultSet of bug IDs instead of BugTasks.
"""
store = IStore(BugTask)
orderby_expression, orderby_joins = _process_order_by(alternatives[0])
decorators = []
+ want = BugTask.bugID if just_bug_ids else BugTask
+
if len(alternatives) == 1:
[query, clauseTables, bugtask_decorator, join_tables,
has_duplicate_results, with_clause] = _build_query(alternatives[0])
@@ -226,10 +228,10 @@
outer_origin = _build_origin(orderby_joins, [])
subquery = Select(BugTask.id, where=query, tables=origin)
result = store.using(*outer_origin).find(
- resultrow, In(BugTask.id, subquery))
+ want, In(BugTask.id, subquery))
else:
origin = _build_origin(join_tables + orderby_joins, clauseTables)
- result = store.using(*origin).find(resultrow, query)
+ result = store.using(*origin).find(want, query)
else:
results = []
@@ -251,7 +253,7 @@
origin = _build_origin(
orderby_joins, [],
start_with=Alias(resultset._get_select(), "BugTask"))
- result = store.using(*origin).find(resultrow)
+ result = store.using(*origin).find(want)
result.order_by(orderby_expression)
return DecoratedResultSet(