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

feat: add python base version #16

Merged
merged 24 commits into from
Aug 17, 2023
Merged

feat: add python base version #16

merged 24 commits into from
Aug 17, 2023

Conversation

danstis
Copy link
Owner

@danstis danstis commented Aug 17, 2023

No description provided.

danstis and others added 24 commits May 14, 2023 12:39
…r the named Asana task in the given project.

# Aider chat conversation:

USER: add the function get_asana_task that is referenced on line 54

ASSISTANT: Sure, I can help with that. We will add the function `get_asana_task` to the `ado_asana_sync.py` file. This function will take two parameters: `asana_project` and `task_name`. It will use the Asana API to fetch tasks from the given project and return the task that matches the given name. If no task is found, it will return `None`.

Here is the code change:

```python
ado_asana_sync.py
<<<<<<< HEAD
=======
def get_asana_task(asana_project, task_name):
    """
    Returns the task gid for the named Asana task in the given project.

    :param asana_project: The gid of the Asana project.
    :type asana_project: str
    :param task_name: The name of the Asana task.
    :type task_name: str
    :return: Task gid or None if no task is found.
    :rtype: str or None
    """
    api_instance = asana.TasksApi(asana_client)
    try:
        # Get all tasks in the project
        api_response = api_instance.get_tasks_in_project(asana_project, completed=False)
        for t in api_response.data:
            if t.name == task_name:
                return t.gid
    except ApiException as e:
        print("Exception when calling TasksApi->get_tasks_in_project: %s\n" % e)
>>>>>>> updated
```

This function uses the `TasksApi` from the Asana client to get all tasks in the given project. It then loops through the tasks and returns the gid of the task that matches the given name. If no task is found, it returns `None`.
…ists.

# Aider chat conversation:

USER: update get_asana_task to return an entire task object if it exists

ASSISTANT: Sure, I can help with that. We will modify the `get_asana_task` function in the `ado_asana_sync.py` file to return the entire task object instead of just the gid.

Here is the code change:

```python
ado_asana_sync.py
<<<<<<< HEAD
def get_asana_task(asana_project, task_name):
    """
    Returns the task gid for the named Asana task in the given project.

    :param asana_project: The gid of the Asana project.
    :type asana_project: str
    :param task_name: The name of the Asana task.
    :type task_name: str
    :return: Task gid or None if no task is found.
    :rtype: str or None
    """
    api_instance = asana.TasksApi(asana_client)
    try:
        # Get all tasks in the project
        api_response = api_instance.get_tasks_in_project(asana_project, completed=False)
        for t in api_response.data:
            if t.name == task_name:
                return t.gid
    except ApiException as e:
        print("Exception when calling TasksApi->get_tasks_in_project: %s\n" % e)
=======
def get_asana_task(asana_project, task_name):
    """
    Returns the entire task object for the named Asana task in the given project.

    :param asana_project: The gid of the Asana project.
    :type asana_project: str
    :param task_name: The name of the Asana task.
    :type task_name: str
    :return: Task object or None if no task is found.
    :rtype: object or None
    """
    api_instance = asana.TasksApi(asana_client)
    try:
        # Get all tasks in the project
        api_response = api_instance.get_tasks_in_project(asana_project, completed=False)
        for t in api_response.data:
            if t.name == task_name:
                return t
    except ApiException as e:
        print("Exception when calling TasksApi->get_tasks_in_project: %s\n" % e)
>>>>>>> updated
```

This change will make the function return the entire task object that matches the given name. If no task is found, it will still return `None`.
# Aider chat conversation:

USER: add a return type to the get_asana_task function

ASSISTANT: To add a return type to the `get_asana_task` function, we need to modify the `ado_asana_sync.py` file.

Here are the changes:

```python
ado_asana_sync.py
<<<<<<< HEAD
def get_asana_task(asana_project, task_name):
=======
def get_asana_task(asana_project, task_name) -> Union[asana.models.task.Task, None]:
>>>>>>> updated
```

This change specifies that the `get_asana_task` function will return either an instance of `asana.models.task.Task` or `None`. The `Union` type hint is used to specify that a value can be one of several types, and is part of the `typing` module.
@danstis danstis merged commit 2667e88 into main Aug 17, 2023
1 check failed
@danstis danstis deleted the python-base branch August 17, 2023 12:39
@sonarcloud
Copy link

sonarcloud bot commented Aug 17, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant