Skip to content

Commit df6e47d

Browse files
authored
feat: allow sorting of Actors collection (#422)
Added new sorting param sortBy for the new feature described in this [Issue](https://app.zenhub.com/workspaces/platform-team-5f6454160d9f82000fa6733f/issues/gh/apify/apify-core/20997) I will wait until [Apify-Core PR](apify/apify-core#21566) is deployed and then will merge this. One note, I am not sure if I added the sortBy parameter correctly. Example code below: `return await self._list(my=my, limit=limit, offset=offset, desc=desc, sortBy=sort_by)` I tried to follow similar examples with a camel case api parameter. Please let me know if this is not the correct syntax.
1 parent 88cc4b7 commit df6e47d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/apify_client/clients/resource_clients/actor_collection.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any
3+
from typing import TYPE_CHECKING, Any, Literal
44

55
from apify_shared.utils import filter_out_none_values_recursively, ignore_docs
66

@@ -26,6 +26,7 @@ def list(
2626
limit: int | None = None,
2727
offset: int | None = None,
2828
desc: bool | None = None,
29+
sort_by: Literal['createdAt', 'lastRunStartedAt'] | None = 'createdAt',
2930
) -> ListPage[dict]:
3031
"""List the Actors the user has created or used.
3132
@@ -36,11 +37,12 @@ def list(
3637
limit: How many Actors to list.
3738
offset: What Actor to include as first when retrieving the list.
3839
desc: Whether to sort the Actors in descending order based on their creation date.
40+
sort_by: Field to sort the results by.
3941
4042
Returns:
4143
The list of available Actors matching the specified filters.
4244
"""
43-
return self._list(my=my, limit=limit, offset=offset, desc=desc)
45+
return self._list(my=my, limit=limit, offset=offset, desc=desc, sortBy=sort_by)
4446

4547
def create(
4648
self,
@@ -150,6 +152,7 @@ async def list(
150152
limit: int | None = None,
151153
offset: int | None = None,
152154
desc: bool | None = None,
155+
sort_by: Literal['createdAt', 'lastRunStartedAt'] | None = 'createdAt',
153156
) -> ListPage[dict]:
154157
"""List the Actors the user has created or used.
155158
@@ -160,11 +163,12 @@ async def list(
160163
limit: How many Actors to list.
161164
offset: What Actor to include as first when retrieving the list.
162165
desc: Whether to sort the Actors in descending order based on their creation date.
166+
sort_by: Field to sort the results by.
163167
164168
Returns:
165169
The list of available Actors matching the specified filters.
166170
"""
167-
return await self._list(my=my, limit=limit, offset=offset, desc=desc)
171+
return await self._list(my=my, limit=limit, offset=offset, desc=desc, sortBy=sort_by)
168172

169173
async def create(
170174
self,

0 commit comments

Comments
 (0)