문제

I'm creating a panel for Panic's StatusBoard to show projects from my workspace, with the ratio of completed tasks to total tasks.

I can do this currently, based on what I'm seeing in the API Docs, the problem is I need to make about 40 requests to get all the info I need and this number will only get larger as more tasks are added to my selected projects.

I'm looping through each selected project and getting each individual task, but all I'm taking from that task object in the 'completed' property.

Is there a way to get each project with completed counts and total counts as properties?

Or, is there another approach that I could take so that I don't get timeout errors when making so many requests..

도움이 되었습니까?

해결책

You should be able to do this by getting all of the tasks for a project and selecting the completed field using the ?opt_fields=completed option on your request.

E.g., http://app.asana.com/api/1.0/projects/[project]/tasks?opt_fields=completed

where [project] is the project ID you're querying. This will return the completed status of all tasks within a given project. You would then iterate over the returned tasks and count the completed/uncompleted statuses.

Note that with the opt_fields option, only the identified fields will be returned.

다른 팁

The answer by jbl is correct, you can use the opt_fields to get the completed field and use it to calculate your ratio.

As I wondered if it was possible with the Asana client library I've written in PHP based on Guzzle I've coded an example for your question. I needed to add the opt_fields option but afterwards it was easy to make an example that does what you need. Maybe you can use it for your StatusBoard development?

You can find the example here: https://github.com/arendjantetteroo/guzzle-asana/blob/master/examples/completedvstotalratio.php

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top