Get tasks count overdue

Hi,

I am trying to get the overdue task count.

I see that

GET /projects/{project_gid}/task_counts

reports the task count but the overdued ones

{
  "data": {
    "num_completed_milestones": 3,
    "num_completed_tasks": 150,
    "num_incomplete_milestones": 7,
    "num_incomplete_tasks": 50,
    "num_milestones": 10,
    "num_tasks": 200
  }
}

Is there a way to get the overdue task similar what is shown in the portfolio summary

Thank you.

1 Like

@Bastien_Siebman I’m sure you’re doing this in Pulse; I guess it has to calculated manually by getting the actual tasks?

Hi Phil, thank for your reply . I wanted to avoid for every project in my portfolio to retrieve all the tasks and for every task get the details in order to get the due_date. These will be too many queries to GET /tasks/{task_gid}

For every project in portfolio
For every task in project
GET /tasks/{task_gid}

I believe there is no way around querying all tasks. However if you use the search endpoint you can give several projects…

1 Like

Hi Bastien,

Thank you for the reply.

If I use the advanced search I can retrieve the overdue task but I need to perform an advanced search (resources consuming) for every project. If I enter several projects I don’t see the way to know what tasks belongs to what project.

For example, for 2 projects

/tasks/search?projects.any=1202018361552925,1202092836384573&due_on.before=2022-04-13&completed=false

{
    "data": [
        {
            "gid": "1202092836384582",
            "name": "Set final deadline",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384584",
            "name": "new task",
            "resource_type": "task"
        },
        {
            "gid": "1202093382152270",
            "name": "subtask1",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384589",
            "name": "Determine project goal",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384587",
            "name": "Milestone1",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384580",
            "name": "Schedule kickoff meeting",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384577",
            "name": "task 2",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384575",
            "name": "Milestone2",
            "resource_type": "task"
        },
        {
            "gid": "1202092836384568",
            "name": "task 2",
            "resource_type": "task"
        },
        {
            "gid": "1202048281732247",
            "name": "new task",
            "resource_type": "task"
        },
        {
            "gid": "1202048281732251",
            "name": "subtask1",
            "resource_type": "task"
        },
        {
            "gid": "1202018361552944",
            "name": "Set final deadline",
            "resource_type": "task"
        },
        {
            "gid": "1202018361552940",
            "name": "Determine project goal",
            "resource_type": "task"
        },
        {
            "gid": "1202018361552971",
            "name": "Milestone1",
            "resource_type": "task"
        },
        {
            "gid": "1202018361552942",
            "name": "Schedule kickoff meeting",
            "resource_type": "task"
        },
        {
            "gid": "1202018361552973",
            "name": "Milestone2",
            "resource_type": "task"
        }
    ]
}

So for me, the api

GET /projects/{project_gid}/task_counts

would be nice to return

num_overdue_task

It would reduce the number of API calls to get the same value and you can always avoid returning the field with opt_fields.

When you run the search you should use opt_fields to ask Asana for specific fields, in that case the projects of the task. Let me know if that helps.

Hi again Bastien,

As a leason learned from this topic client.statusupdates.getStatus not working - #4 by Bastien_Siebman

you’re right, with opt_fields I can ask for fields that normally does not appear.

Anyway, I still believe that including the field in the /task_counts api would be more efficient in this particular scenario :slightly_smiling_face:

Thank you.

I believe the Asana API team is a bit swamped so I would not expect this to be added anytime soon :sweat_smile: