From 262cbda49306d2ed5b3bfa916c3bf197e3239fda Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 4 Mar 2024 17:46:11 +0100 Subject: [PATCH] clockify use folder and task entity --- .../modules/clockify/clockify_module.py | 27 +++++++------------ .../launcher_actions/ClockifyStart.py | 25 +++++++---------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/client/ayon_core/modules/clockify/clockify_module.py b/client/ayon_core/modules/clockify/clockify_module.py index 58407bfe94..d2ee4f1e1e 100644 --- a/client/ayon_core/modules/clockify/clockify_module.py +++ b/client/ayon_core/modules/clockify/clockify_module.py @@ -3,7 +3,6 @@ import threading import time from ayon_core.modules import AYONAddon, ITrayModule, IPluginPaths -from ayon_core.client import get_asset_by_name from .constants import CLOCKIFY_FTRACK_USER_PATH, CLOCKIFY_FTRACK_SERVER_PATH @@ -255,33 +254,27 @@ class ClockifyModule(AYONAddon, ITrayModule, IPluginPaths): if not self.clockify_api.get_api_key(): return + project_name = input_data.get("project_name") + folder_path = input_data.get("folder_path") task_name = input_data.get("task_name") + task_type = input_data.get("task_type") + if not all((project_name, folder_path, task_name, task_type)): + return # Concatenate hierarchy and task to get description - description_items = list(input_data.get("hierarchy", [])) - description_items.append(task_name) - description = "/".join(description_items) + description = "/".join([folder_path.lstrip("/"), task_name]) # Check project existence - project_name = input_data.get("project_name") project_id = self._verify_project_exists(project_name) if not project_id: return # Setup timer tags - tag_ids = [] - tag_name = input_data.get("task_type") - if not tag_name: - # no task_type found in the input data - # if the timer is restarted by idle time (bug?) - asset_name = input_data["hierarchy"][-1] - asset_doc = get_asset_by_name(project_name, asset_name) - task_info = asset_doc["data"]["tasks"][task_name] - tag_name = task_info.get("type", "") - if not tag_name: - self.log.info("No tag information found for the timer") + if not task_type: + self.log.info("No tag information found for the timer") - task_tag_id = self.clockify_api.get_tag_id(tag_name) + tag_ids = [] + task_tag_id = self.clockify_api.get_tag_id(task_type) if task_tag_id is not None: tag_ids.append(task_tag_id) diff --git a/client/ayon_core/modules/clockify/launcher_actions/ClockifyStart.py b/client/ayon_core/modules/clockify/launcher_actions/ClockifyStart.py index f7dd1772b0..61c5eac2f5 100644 --- a/client/ayon_core/modules/clockify/launcher_actions/ClockifyStart.py +++ b/client/ayon_core/modules/clockify/launcher_actions/ClockifyStart.py @@ -1,4 +1,5 @@ -from ayon_core.client import get_asset_by_name +import ayon_api + from ayon_core.pipeline import LauncherAction from openpype_modules.clockify.clockify_api import ClockifyAPI @@ -21,24 +22,18 @@ class ClockifyStart(LauncherAction): user_id = self.clockify_api.user_id workspace_id = self.clockify_api.workspace_id project_name = session["AYON_PROJECT_NAME"] - asset_name = session["AYON_FOLDER_PATH"] + folder_path = session["AYON_FOLDER_PATH"] task_name = session["AYON_TASK_NAME"] - description = asset_name + description = "/".join([folder_path.lstrip("/"), task_name]) - # fetch asset docs - asset_doc = get_asset_by_name(project_name, asset_name) + # fetch folder entity + folder_entity = ayon_api.get_folder_by_path(project_name, folder_path) + task_entity = ayon_api.get_task_by_name( + project_name, folder_entity["id"], task_name + ) # get task type to fill the timer tag - task_info = asset_doc["data"]["tasks"][task_name] - task_type = task_info["type"] - - # check if the task has hierarchy and fill the - parents_data = asset_doc["data"] - if parents_data is not None: - description_items = parents_data.get("parents", []) - description_items.append(asset_name) - description_items.append(task_name) - description = "/".join(description_items) + task_type = task_entity["taskType"] project_id = self.clockify_api.get_project_id( project_name, workspace_id