Skip to content

Commit 4629eb4

Browse files
authored
Merge pull request #33 from bugout-dev/fix-search-add-order
Added order argument to journal search method
2 parents 9e84da9 + 3aad3f3 commit 4629eb4

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

bugout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
__email__ = "engineering@bugout.dev"
99
__license__ = "MIT"
10-
__version__ = "0.1.16"
10+
__version__ = "0.1.17"
1111

1212
__all__ = (
1313
"__author__",

bugout/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .calls import ping
66
from .group import Group
77
from .humbug import Humbug
8-
from .journal import Journal
8+
from .journal import Journal, SearchOrder
99
from .resource import Resource
1010
from .user import User
1111
from .settings import BUGOUT_BROOD_URL, BUGOUT_SPIRE_URL, REQUESTS_TIMEOUT
@@ -685,10 +685,11 @@ def search(
685685
offset: int = 0,
686686
content: bool = True,
687687
timeout: float = REQUESTS_TIMEOUT,
688+
order: SearchOrder = SearchOrder.DESCENDING,
688689
) -> data.BugoutSearchResults:
689690
self.journal.timeout = timeout
690691
return self.journal.search(
691-
token, journal_id, query, filters, limit, offset, content
692+
token, journal_id, query, filters, limit, offset, content, order=order
692693
)
693694

694695
# Public

bugout/journal.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from enum import Enum
12
from typing import Any, List, Optional, Union
23
import uuid
34

@@ -22,6 +23,11 @@
2223
from .settings import REQUESTS_TIMEOUT
2324

2425

26+
class SearchOrder(Enum):
27+
ASCENDING = "asc"
28+
DESCENDING = "desc"
29+
30+
2531
class Journal:
2632
"""
2733
Represent a journal from Bugout.
@@ -410,6 +416,7 @@ def search(
410416
limit: int = 10,
411417
offset: int = 0,
412418
content: bool = True,
419+
order: SearchOrder = SearchOrder.DESCENDING,
413420
) -> BugoutSearchResults:
414421
search_path = f"journals/{journal_id}/search"
415422
headers = {
@@ -421,6 +428,7 @@ def search(
421428
"limit": limit,
422429
"offset": offset,
423430
"content": content,
431+
"order": order.value,
424432
}
425433
result = self._call(
426434
method=Method.get, path=search_path, params=query_params, headers=headers

0 commit comments

Comments
 (0)