Skip to content

Commit

Permalink
Merge pull request #90 from ynput/enhancement/more-folders-filtering
Browse files Browse the repository at this point in the history
Folders: More filtering options
  • Loading branch information
iLLiCiTiT authored Sep 7, 2023
2 parents 3b9d58a + c62643e commit 1ac320b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ayon_api/graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def folders_graphql_query(fields):
parent_folder_ids_var = query.add_variable("parentFolderIds", "[String!]")
folder_paths_var = query.add_variable("folderPaths", "[String!]")
folder_names_var = query.add_variable("folderNames", "[String!]")
folder_types_var = query.add_variable("folderTypes", "[String!]")
statuses_var = query.add_variable("folderStatuses", "[String!]")
has_products_var = query.add_variable("folderHasProducts", "Boolean!")

project_field = query.add_field("project")
Expand All @@ -185,6 +187,8 @@ def folders_graphql_query(fields):
folders_field.set_filter("parentIds", parent_folder_ids_var)
folders_field.set_filter("names", folder_names_var)
folders_field.set_filter("paths", folder_paths_var)
folders_field.set_filter("folderTypes", folder_types_var)
folders_field.set_filter("statuses", statuses_var)
folders_field.set_filter("hasProducts", has_products_var)

nested_fields = fields_to_dict(fields)
Expand Down
18 changes: 18 additions & 0 deletions ayon_api/server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3515,7 +3515,9 @@ def get_folders(
folder_ids=None,
folder_paths=None,
folder_names=None,
folder_types=None,
parent_ids=None,
statuses=None,
active=True,
fields=None,
own_attributes=False
Expand All @@ -3536,8 +3538,12 @@ def get_folders(
for filtering.
folder_names (Optional[Iterable[str]]): Folder names used
for filtering.
folder_types (Optional[Iterable[str]]): Folder types used
for filtering.
parent_ids (Optional[Iterable[str]]): Ids of folder parents.
Use 'None' if folder is direct child of project.
statuses (Optional[Iterable[str]]): Folder statuses used
for filtering.
active (Optional[bool]): Filter active/inactive folders.
Both are returned if is set to None.
fields (Optional[Iterable[str]]): Fields to be queried for
Expand Down Expand Up @@ -3574,6 +3580,18 @@ def get_folders(
return
filters["folderNames"] = list(folder_names)

if folder_types is not None:
folder_types = set(folder_types)
if not folder_types:
return
filters["folderTypes"] = list(folder_types)

if statuses is not None:
statuses = set(statuses)
if not statuses:
return
filters["folderStatuses"] = list(statuses)

if parent_ids is not None:
parent_ids = set(parent_ids)
if not parent_ids:
Expand Down

0 comments on commit 1ac320b

Please sign in to comment.