Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more filters to retrieve episode tasks #336

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions gazu/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def import_entities(entities, client=default):
"""
Import entities from another instance to target instance (keep id and audit
dates).

Args:
entities (list): Entities to import.

Expand All @@ -69,6 +70,7 @@ def import_tasks(tasks, client=default):
"""
Import tasks from another instance to target instance (keep id and audit
dates).

Args:
tasks (list): Tasks to import.

Expand All @@ -82,6 +84,7 @@ def import_entity_links(links, client=default):
"""
Import enitity links from another instance to target instance (keep id and
audit dates).

Args:
links (list): Entity links to import.

Expand Down Expand Up @@ -292,7 +295,8 @@ def get_sync_person_id_map(source_client, target_client):
def push_assets(project_source, project_target, client_source, client_target):
"""
Copy assets from source to target and preserve audit fields (`id`,
`created_at`, and `updated_at`)
`created_at`, and `updated_at`).

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand Down Expand Up @@ -321,6 +325,7 @@ def push_episodes(
"""
Copy episodes from source to target and preserve audit fields (`id`,
`created_at`, and `updated_at`)

Args:
project_source (dict): The project to get episodes from
project_target (dict): The project to push episodes to
Expand All @@ -344,6 +349,7 @@ def push_sequences(
"""
Copy sequences from source to target and preserve audit fields (`id`,
`created_at`, and `updated_at`)

Args:
project_source (dict): The project to get sequences from
project_target (dict): The project to push sequences to
Expand All @@ -364,7 +370,8 @@ def push_sequences(
def push_shots(project_source, project_target, client_source, client_target):
"""
Copy shots from source to target and preserve audit fields (`id`,
`created_at`, and `updated_at`)
`created_at`, and `updated_at`).

Args:
project_source (dict): The project to get shots from
project_target (dict): The project to push shots to
Expand All @@ -386,8 +393,9 @@ def push_entity_links(
project_source, project_target, client_source, client_target
):
"""
Copy assets from source to target and preserve audit fields (`id`,
`created_at`, and `updated_at`)
Copy entity links (breakdown, concepts) from source to target and preserve
audit fields (`id`, `created_at`, and `updated_at`).

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand All @@ -408,7 +416,8 @@ def push_project_entities(
):
"""
Copy assets, episodes, sequences, shots and entity links from source to
target and preserve audit fields (`id`, `created_at`, and `updated_at`)
target and preserve audit fields (`id`, `created_at`, and `updated_at`).

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand Down Expand Up @@ -445,6 +454,7 @@ def push_tasks(
Copy tasks from source to target and preserve audit fields (`id`,
`created_at`, and `updated_at`)
Attachments and previews are created too.

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand Down Expand Up @@ -479,6 +489,7 @@ def push_tasks_comments(project_source, client_source, client_target):
Create a new comment into target api for each comment in source project
but preserve only `created_at` field.
Attachments and previews are created too.

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand Down Expand Up @@ -508,6 +519,7 @@ def push_task_comments(
Create a new comment into target api for each comment in source task
but preserve only `created_at` field.
Attachments and previews are created too.

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand Down Expand Up @@ -547,6 +559,7 @@ def push_task_comment(
Create a new comment into target api for each comment in source task
but preserve only `created_at` field.
Attachments and previews are created too.

Args:
project_source (dict): The project to get assets from
project_target (dict): The project to push assets to
Expand Down
44 changes: 32 additions & 12 deletions gazu/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,31 @@ def all_tasks_for_task_status(project, task_type, task_status, client=default):


@cache
def all_tasks_for_task_type(project, task_type, client=default):
def all_tasks_for_task_type(
project,
task_type,
episode=None,
client=default
):
"""
Args:
project (str / dict): The project dict or the project ID.
task_type (str / dict): The task type dict or ID.
episode_id (str / dict): The episode dict or ID.

Returns:
list: Tasks for given project and task type.
"""
project = normalize_model_parameter(project)
task_type = normalize_model_parameter(task_type)
return raw.fetch_all(
"tasks",
{
"project_id": project["id"],
"task_type_id": task_type["id"],
},
client=client,
)
params = {
"project_id": project["id"],
"task_type_id": task_type["id"],
}
if episode is not None:
episode = normalize_model_parameter(episode)
params["episode_id"] = episode["id"]
return raw.fetch_all("tasks", params, client=client)


@cache
Expand Down Expand Up @@ -1260,17 +1266,31 @@ def get_task_url(task, client=default):
)


def all_tasks_for_project(project, client=default):
def all_tasks_for_project(
project,
task_type=None,
episode=None,
client=default
):
"""
Args:
project (str / dict): The project
project (str / dict): The project (or its ID) to get tasks from.
task_type (str / dict): The task type (or its ID) to filter tasks.
episode (str / dict): The episode (or its ID) to filter tasks.

Returns:
dict: Tasks related to given project.
"""
project = normalize_model_parameter(project)
path = "/data/projects/%s/tasks" % project["id"]
return raw.get(path, client=client)
params = {}
if task_type is not None:
task_type = normalize_model_parameter(task_type)
params["task_type_id"] = task_type["id"]
if episode is not None:
episode = normalize_model_parameter(episode)
params["episode_id"] = episode["id"]
return raw.get(path, params=params, client=client)


def update_comment(comment, client=default):
Expand Down
Loading