mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #2905 from pypeclub/bugfix/OP-2942_Ftrack-missing-id-on-editorial-publish
Ftrack: Missing Ftrack id after editorial publish
This commit is contained in:
commit
fcbb144808
3 changed files with 90 additions and 12 deletions
|
|
@ -199,8 +199,10 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
if proj:
|
||||
ftrack_id = proj["data"].get("ftrackId")
|
||||
if ftrack_id is None:
|
||||
ftrack_id = self._update_project_ftrack_id()
|
||||
proj["data"]["ftrackId"] = ftrack_id
|
||||
self.handle_missing_ftrack_id(proj)
|
||||
ftrack_id = proj["data"]["ftrackId"]
|
||||
self._avalon_ents_by_ftrack_id[ftrack_id] = proj
|
||||
|
||||
self._avalon_ents_by_ftrack_id[ftrack_id] = proj
|
||||
for ent in ents:
|
||||
ftrack_id = ent["data"].get("ftrackId")
|
||||
|
|
@ -209,15 +211,78 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
self._avalon_ents_by_ftrack_id[ftrack_id] = ent
|
||||
return self._avalon_ents_by_ftrack_id
|
||||
|
||||
def _update_project_ftrack_id(self):
|
||||
ftrack_id = self.cur_project["id"]
|
||||
def handle_missing_ftrack_id(self, doc):
|
||||
# TODO handling of missing ftrack id is primarily issue of editorial
|
||||
# publishing it would be better to find out what causes that
|
||||
# ftrack id is removed during the publishing
|
||||
ftrack_id = doc["data"].get("ftrackId")
|
||||
if ftrack_id is not None:
|
||||
return
|
||||
|
||||
if doc["type"] == "project":
|
||||
ftrack_id = self.cur_project["id"]
|
||||
|
||||
self.dbcon.update_one(
|
||||
{"type": "project"},
|
||||
{"$set": {
|
||||
"data.ftrackId": ftrack_id,
|
||||
"data.entityType": self.cur_project.entity_type
|
||||
}}
|
||||
)
|
||||
|
||||
doc["data"]["ftrackId"] = ftrack_id
|
||||
doc["data"]["entityType"] = self.cur_project.entity_type
|
||||
self.log.info("Updated ftrack id of project \"{}\"".format(
|
||||
self.cur_project["full_name"]
|
||||
))
|
||||
return
|
||||
|
||||
if doc["type"] != "asset":
|
||||
return
|
||||
|
||||
doc_parents = doc.get("data", {}).get("parents")
|
||||
if doc_parents is None:
|
||||
return
|
||||
|
||||
entities = self.process_session.query((
|
||||
"select id, link from TypedContext"
|
||||
" where project_id is \"{}\" and name is \"{}\""
|
||||
).format(self.cur_project["id"], doc["name"])).all()
|
||||
self.log.info("Entities: {}".format(str(entities)))
|
||||
matching_entity = None
|
||||
for entity in entities:
|
||||
parents = []
|
||||
for item in entity["link"]:
|
||||
if item["id"] == entity["id"]:
|
||||
break
|
||||
low_type = item["type"].lower()
|
||||
if low_type == "typedcontext":
|
||||
parents.append(item["name"])
|
||||
if doc_parents == parents:
|
||||
matching_entity = entity
|
||||
break
|
||||
|
||||
if matching_entity is None:
|
||||
return
|
||||
|
||||
ftrack_id = matching_entity["id"]
|
||||
self.dbcon.update_one(
|
||||
{"type": "project"},
|
||||
{"$set": {"data.ftrackId": ftrack_id}}
|
||||
{"_id": doc["_id"]},
|
||||
{"$set": {
|
||||
"data.ftrackId": ftrack_id,
|
||||
"data.entityType": matching_entity.entity_type
|
||||
}}
|
||||
)
|
||||
doc["data"]["ftrackId"] = ftrack_id
|
||||
doc["data"]["entityType"] = matching_entity.entity_type
|
||||
|
||||
return ftrack_id
|
||||
entity_path_items = []
|
||||
for item in entity["link"]:
|
||||
entity_path_items.append(item["name"])
|
||||
self.log.info("Updated ftrack id of entity \"{}\"".format(
|
||||
"/".join(entity_path_items)
|
||||
))
|
||||
self._avalon_ents_by_ftrack_id[ftrack_id] = doc
|
||||
|
||||
@property
|
||||
def avalon_subsets_by_parents(self):
|
||||
|
|
@ -857,7 +922,14 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
if vis_par is None:
|
||||
vis_par = proj["_id"]
|
||||
parent_ent = self.avalon_ents_by_id[vis_par]
|
||||
parent_ftrack_id = parent_ent["data"]["ftrackId"]
|
||||
|
||||
parent_ftrack_id = parent_ent["data"].get("ftrackId")
|
||||
if parent_ftrack_id is None:
|
||||
self.handle_missing_ftrack_id(parent_ent)
|
||||
parent_ftrack_id = parent_ent["data"].get("ftrackId")
|
||||
if parent_ftrack_id is None:
|
||||
continue
|
||||
|
||||
parent_ftrack_ent = self.ftrack_ents_by_id.get(
|
||||
parent_ftrack_id
|
||||
)
|
||||
|
|
@ -2128,7 +2200,13 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
vis_par = avalon_ent["parent"]
|
||||
|
||||
parent_ent = self.avalon_ents_by_id[vis_par]
|
||||
parent_ftrack_id = parent_ent["data"]["ftrackId"]
|
||||
parent_ftrack_id = parent_ent["data"].get("ftrackId")
|
||||
if parent_ftrack_id is None:
|
||||
self.handle_missing_ftrack_id(parent_ent)
|
||||
parent_ftrack_id = parent_ent["data"].get("ftrackId")
|
||||
if parent_ftrack_id is None:
|
||||
continue
|
||||
|
||||
if parent_ftrack_id not in entities_dict:
|
||||
entities_dict[parent_ftrack_id] = {
|
||||
"children": [],
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ class UserAssigmentEvent(BaseEvent):
|
|||
if not user_id:
|
||||
return None, None
|
||||
|
||||
task = session.query('Task where id is "{}"'.format(task_id)).one()
|
||||
user = session.query('User where id is "{}"'.format(user_id)).one()
|
||||
task = session.query('Task where id is "{}"'.format(task_id)).first()
|
||||
user = session.query('User where id is "{}"'.format(user_id)).first()
|
||||
|
||||
return task, user
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class BaseEvent(BaseHandler):
|
|||
return self._get_entities(
|
||||
event,
|
||||
session,
|
||||
ignore=['socialfeed', 'socialnotification']
|
||||
ignore=['socialfeed', 'socialnotification', 'team']
|
||||
)
|
||||
|
||||
def get_project_name_from_event(self, session, event, project_id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue