Skip to content

Commit

Permalink
cache object types
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Dec 14, 2021
1 parent 3b9db7d commit 0ff12fd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions openpype/modules/default_modules/ftrack/lib/avalon_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ def launch_setup(self, project_full_name):
self._subsets_by_parent_id = None
self._changeability_by_mongo_id = None

self._object_types_by_name = None

self.all_filtered_entities = {}
self.filtered_ids = []
self.not_selected_ids = []
Expand Down Expand Up @@ -651,6 +653,18 @@ def changeability_by_mongo_id(self):
self._bubble_changeability(list(self.subsets_by_parent_id.keys()))
return self._changeability_by_mongo_id

@property
def object_types_by_name(self):
if self._object_types_by_name is None:
object_types_by_name = self.session.query(
"select id, name from ObjectType"
).all()
self._object_types_by_name = {
object_type["name"]: object_type
for object_type in object_types_by_name
}
return self._object_types_by_name

@property
def all_ftrack_names(self):
"""
Expand Down Expand Up @@ -880,10 +894,7 @@ def set_cutom_attributes(self):
custom_attrs, hier_attrs = get_openpype_attr(
self.session, query_keys=self.cust_attr_query_keys
)
ent_types = self.session.query("select id, name from ObjectType").all()
ent_types_by_name = {
ent_type["name"]: ent_type["id"] for ent_type in ent_types
}
ent_types_by_name = self.object_types_by_name
# Custom attribute types
cust_attr_types = self.session.query(
"select id, name from CustomAttributeType"
Expand Down

0 comments on commit 0ff12fd

Please sign in to comment.