Skip to content

Commit

Permalink
Add sort back to messages
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Nov 21, 2023
1 parent 2af2749 commit 32ef4dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mp_api/client/routes/_messages.py
Expand Up @@ -42,6 +42,7 @@ def set_message(
def get_messages(
self,
last_updated: datetime,
sort_fields: list[str] | None = None,
num_chunks: int | None = None,
chunk_size: int = 1000,
all_fields: bool = True,
Expand All @@ -51,6 +52,7 @@ def get_messages(
Args:
last_updated (datetime): Datetime to use to query for newer messages
sort_fields (List[str]): Fields used to sort results. Prefix with '-' to sort in descending order.
num_chunks (int): Maximum number of chunks of data to yield. None will yield all possible.
chunk_size (int): Number of data entries per chunk.
all_fields (bool): Whether to return all fields in the document. Defaults to True.
Expand All @@ -65,6 +67,11 @@ def get_messages(
"""
query_params = {}

if sort_fields:
query_params.update(
{"_sort_fields": ",".join([s.strip() for s in sort_fields])}
)

return self._search(
last_updated=last_updated,
num_chunks=num_chunks,
Expand Down

0 comments on commit 32ef4dd

Please sign in to comment.