Merge lp:~bac/charmworld/bug-1379397 into lp:charmworld
Proposed by
Brad Crittenden
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Brad Crittenden | ||||
Approved revision: | 520 | ||||
Merged at revision: | 518 | ||||
Proposed branch: | lp:~bac/charmworld/bug-1379397 | ||||
Merge into: | lp:charmworld | ||||
Diff against target: |
190 lines (+82/-7) 3 files modified
charmworld/search.py (+16/-1) charmworld/tests/test_search.py (+42/-0) charmworld/views/api/__init__.py (+24/-6) |
||||
To merge this branch: | bzr merge lp:~bac/charmworld/bug-1379397 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Gui Bot | continuous-integration | Approve | |
Charmworld Developers | Pending | ||
Review via email: mp+238457@code.launchpad.net |
Commit message
Add 'start' parameter to API search.
The start is the zero-based index into the search results. It can be used
in conjunction with limit.
https:/
R=jcsackett
Description of the change
Add 'start' parameter to API search.
The start is the zero-based index into the search results. It can be used
in conjunction with limit.
To post a comment you must log in.
Reviewers: mp+238457_ code.launchpad. net,
Message:
Please take a look.
Description:
Add 'start' parameter to API search.
The start is the zero-based index into the search results. It can be
used
in conjunction with limit.
https:/ /code.launchpad .net/~bac/ charmworld/ bug-1379397/ +merge/ 238457
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/158010043/
Affected files (+85, -7 lines): search. py tests/test_ search. py views/api/ __init_ _.py
A [revision details]
M charmworld/
M charmworld/
M charmworld/
Index: [revision details] 20140905151929- pbmcu2i5i3s9vgk x
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: charmworld/ search. py search. py' search. py 2014-07-15 19:09:59 +0000 search. py 2014-10-15 14:45:53 +0000
=== modified file 'charmworld/
--- charmworld/
+++ charmworld/
@@ -63,6 +63,10 @@
"""Raised when a negative limit is specified."""
+class InvalidStart( Exception) : ping(Exception) :
+ """Raised when an invalid 'start' is specified."""
+
+
class IncompatibleMap
"""Raised when desired mapping is not compatible with active
mapping."""
@@ -615,7 +619,7 @@
limit=None, valid_only=True, sort=None,
autocomplete= False, doctype=CHARM,
def api_search(self, text='', filters=None, type_=None,
- min_score=None):
+ min_score=None, start=None):
"""Search charms and bundles (as used by the API).
:param text: A string to search for -- will be analyzed (i.e. split
overridden by use of 'charm:' or 'bundle:' query string prefix.
min_score. start+limit] . Start is zero-based. <charm| bundle> , data=entity}.
raise NegativeLimit()
@@ -641,12 +645,18 @@
:param min_score: Only return results with a score of at least
+ :param start: Return the 'limit' number of items from the start
+ index, e.g. items[start:
return: A list of {doctype=
"""
if limit is not None:
if limit < 0:
+ if start is not None: doctype_ from_search_ terms(
+ if start < 0:
+ raise InvalidStart()
+
text, doctype, all_requested = extract_
text, doctype)
@@ -679,11 +689,17 @@
limit = min(limit, self.default_ search_ limit)
else:
+ if start is not None and limit is not None: _search( dsl, limit)
+ limit = limit + start
+
try:
hits = self._unlimited
except ElasticHttpError:
hits = []
+ if start is not None:
dict(doctype= hit['_type' ], data=hit[ '_source' ]['data' ])
+ hits = hits[start:]
+
return [
for hit in hits]
Index: charmworld/ tests/test_ search. py tests/test_ search. py' tests/test_ search. py 2014-07-15 19:09:59 +0000 tests/test_ search. py 2014-10-15 14...
=== modified file 'charmworld/
--- charmworld/
+++ charmworld/