mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1558 from ynput/bugfix/product-types-fetching-fix
Loader tool: Fix product types fetching
This commit is contained in:
commit
7d3a85aac0
1 changed files with 20 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Iterable, Optional
|
|||
|
||||
import arrow
|
||||
import ayon_api
|
||||
from ayon_api.graphql_queries import project_graphql_query
|
||||
from ayon_api.operations import OperationsSession
|
||||
|
||||
from ayon_core.lib import NestedCacheItem
|
||||
|
|
@ -202,7 +203,7 @@ class ProductsModel:
|
|||
cache = self._product_type_items_cache[project_name]
|
||||
if not cache.is_valid:
|
||||
icons_mapping = self._get_product_type_icons(project_name)
|
||||
product_types = ayon_api.get_project_product_types(project_name)
|
||||
product_types = self._get_project_product_types(project_name)
|
||||
cache.update_data([
|
||||
ProductTypeItem(
|
||||
product_type["name"],
|
||||
|
|
@ -462,6 +463,24 @@ class ProductsModel:
|
|||
PRODUCTS_MODEL_SENDER
|
||||
)
|
||||
|
||||
def _get_project_product_types(self, project_name: str) -> list[dict]:
|
||||
"""This is a temporary solution for product types fetching.
|
||||
|
||||
There was a bug in ayon_api.get_project(...) which did not use GraphQl
|
||||
but REST instead. That is fixed in ayon-python-api 1.2.6 that will
|
||||
be as part of ayon launcher 1.4.3 release.
|
||||
|
||||
"""
|
||||
if not project_name:
|
||||
return []
|
||||
query = project_graphql_query({"productTypes.name"})
|
||||
query.set_variable_value("projectName", project_name)
|
||||
parsed_data = query.query(ayon_api.get_server_api_connection())
|
||||
project = parsed_data["project"]
|
||||
if project is None:
|
||||
return []
|
||||
return project["productTypes"]
|
||||
|
||||
def _get_product_type_icons(
|
||||
self, project_name: Optional[str]
|
||||
) -> ProductTypeIconMapping:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue