diff --git a/services/processor/processor/default_handlers/event_sync_from_ftrack.py b/services/processor/processor/default_handlers/event_sync_from_ftrack.py index 4d0bac3..bb85ea3 100644 --- a/services/processor/processor/default_handlers/event_sync_from_ftrack.py +++ b/services/processor/processor/default_handlers/event_sync_from_ftrack.py @@ -41,11 +41,21 @@ UNKNOWN_VALUE = object() +DEFAULT_ATTRS_MAPPING = { + "startdate": "startDate", + "enddate": "endDate", + "description": "description", +} + class SyncProcess: interest_base_types = ["show", "task"] ignore_ent_types = ["Milestone"] - ignore_change_keys = ["statusid", "thumbid"] + ignore_change_keys = [ + "statusid", + "thumbid", + "priorityid", + ] project_query = ( "select id, full_name, name, custom_attributes," @@ -1320,13 +1330,27 @@ def _propagate_attrib_changes(self): if key == "typeid" and entity.entity_type == "task": task_type_changes[ftrack_id] = (entity, info) - dst_key = key - if key == CUST_ATTR_TOOLS: + default_attr_key = DEFAULT_ATTRS_MAPPING.get(key) + + if default_attr_key is not None: + dst_key = default_attr_key + elif key == CUST_ATTR_TOOLS: dst_key = "tools" + else: + dst_key = key + if dst_key not in entity.attribs: continue - if value is not None: + if default_attr_key is not None: + if value is not None and key in ("startdate", "enddate"): + date = arrow.get(value) + # Shift date to 00:00:00 of the day + # - ftrack is returning e.g. '2024-10-29T22:00:00' + # for '2024-10-30' + value = str(date.shift(hours=24 - date.hour)) + + elif value is not None: if key in FPS_KEYS: value = convert_to_fps(value) else: @@ -1337,6 +1361,7 @@ def _propagate_attrib_changes(self): continue value = self._convert_value_by_cust_attr_conf( value, attr) + entity.attribs[dst_key] = value self._propagate_task_type_changes(task_type_changes) diff --git a/services/processor/processor/lib/sync_from_ftrack.py b/services/processor/processor/lib/sync_from_ftrack.py index b994bf6..8e75ed6 100644 --- a/services/processor/processor/lib/sync_from_ftrack.py +++ b/services/processor/processor/lib/sync_from_ftrack.py @@ -3,6 +3,7 @@ import time import logging +import arrow from ayon_api import ( get_project, create_project, @@ -308,7 +309,8 @@ def sync_to_server(self): self.log.info("Querying project hierarchy from ftrack") ft_entities = ft_session.query(( - "select id, name, parent_id, type_id, object_type_id" + "select id, name, parent_id, type_id, object_type_id, status_id" + ", start_date, end_date, description" #, bid, status_id" " from TypedContext where project_id is \"{}\"" ).format(ft_project["id"])).all() t_ft_entities_4 = time.perf_counter() @@ -707,6 +709,23 @@ def update_attributes_from_ftrack( ]) entity.attribs[FTRACK_ID_ATTRIB] = ftrack_id entity.attribs[FTRACK_PATH_ATTRIB] = path + + for attr_name, value in ( + ("startDate", ft_entity["start_date"]), + ("endDate", ft_entity["end_date"]), + ("description", ft_entity.get("description")), + ): + if value is None or attr_name not in entity.attribs: + continue + + if isinstance(value, arrow.Arrow): + # Shift date to 00:00:00 of the day + # - ftrack is returning e.g. '2024-10-29T22:00:00' + # for '2024-10-30' + value = str(value.shift(hours=24 - value.hour)) + + entity.attribs[attr_name] = str(value) + # ftrack id can not be available if ftrack entity was recreated # during immutable entity processing attribute_values = cust_attr_value_by_entity_id[ftrack_id]