From be9e516971aa0e29d7589510c39cea2d7ae6ace6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 4 Jan 2021 16:52:35 +0100 Subject: [PATCH 1/4] move entities query in code --- pype/modules/ftrack/lib/avalon_sync.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pype/modules/ftrack/lib/avalon_sync.py b/pype/modules/ftrack/lib/avalon_sync.py index 7ff5283d6a..3e6ef94e41 100644 --- a/pype/modules/ftrack/lib/avalon_sync.py +++ b/pype/modules/ftrack/lib/avalon_sync.py @@ -435,11 +435,6 @@ class SyncEntitiesFactory: "message": "Synchronization failed" } - # Find all entities in project - all_project_entities = self.session.query( - self.entities_query.format(ft_project_id) - ).all() - # Store entities by `id` and `parent_id` entities_dict = collections.defaultdict(lambda: { "children": list(), @@ -453,6 +448,10 @@ class SyncEntitiesFactory: "tasks": {} }) + # Find all entities in project + all_project_entities = self.session.query( + self.entities_query.format(ft_project_id) + ).all() for entity in all_project_entities: parent_id = entity["parent_id"] entity_type = entity.entity_type From f8b21a77956e7654e2a1236c4c1044229dc1216e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 4 Jan 2021 16:52:43 +0100 Subject: [PATCH 2/4] added type_id to queried attributes --- pype/modules/ftrack/lib/avalon_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/modules/ftrack/lib/avalon_sync.py b/pype/modules/ftrack/lib/avalon_sync.py index 3e6ef94e41..e0842a26c5 100644 --- a/pype/modules/ftrack/lib/avalon_sync.py +++ b/pype/modules/ftrack/lib/avalon_sync.py @@ -320,7 +320,7 @@ class SyncEntitiesFactory: " from Project where full_name is \"{}\"" ) entities_query = ( - "select id, name, parent_id, link" + "select id, name, type_id, parent_id, link" " from TypedContext where project_id is \"{}\"" ) ignore_custom_attr_key = "avalon_ignore_sync" From 68e2648a4c7a93cf7ba11618e2741dbf4ff85794 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 4 Jan 2021 16:52:54 +0100 Subject: [PATCH 3/4] prepare task types before entities loop --- pype/modules/ftrack/lib/avalon_sync.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pype/modules/ftrack/lib/avalon_sync.py b/pype/modules/ftrack/lib/avalon_sync.py index e0842a26c5..b4b65551fe 100644 --- a/pype/modules/ftrack/lib/avalon_sync.py +++ b/pype/modules/ftrack/lib/avalon_sync.py @@ -452,6 +452,11 @@ class SyncEntitiesFactory: all_project_entities = self.session.query( self.entities_query.format(ft_project_id) ).all() + task_types = self.session.query("select id, name from Type").all() + task_type_names_by_id = { + task_type["id"]: task_type["name"] + for task_type in task_types + } for entity in all_project_entities: parent_id = entity["parent_id"] entity_type = entity.entity_type From 0a42dcd6e7a0b7578ee2f303c32d2990e2df17b5 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 4 Jan 2021 16:53:09 +0100 Subject: [PATCH 4/4] do not acces type name through entities but use prequeried types --- pype/modules/ftrack/lib/avalon_sync.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pype/modules/ftrack/lib/avalon_sync.py b/pype/modules/ftrack/lib/avalon_sync.py index b4b65551fe..c54006474e 100644 --- a/pype/modules/ftrack/lib/avalon_sync.py +++ b/pype/modules/ftrack/lib/avalon_sync.py @@ -466,7 +466,8 @@ class SyncEntitiesFactory: elif entity_type_low == "task": # enrich task info with additional metadata - task = {"type": entity["type"]["name"]} + task_type_name = task_type_names_by_id[entity["type_id"]] + task = {"type": task_type_name} entities_dict[parent_id]["tasks"][entity["name"]] = task continue