Luis Novo
Luis Novo

Reputation: 640

What's the best way to retrieve today's tasks from Asana?

I am trying to pull up a page that shows all the tasks that are assigned to me and that are marked as today.

gem 'asana', git: 'https://github.com/phcyso/asana.git'

//assume w is a valid workspace
@tasks1 = w.tasks(Asana::User.me.id)
<% @tasks.each do |t2| %>
    <% if t2.assignee_status == "today" and t2.completed == false %>
        <li class="list-group-item"><%=t2.name%></li>
    <% end %>
<% end %>

The issue is that this is waaaaaay to slow since it iterates through my entire task list to find what's undone and marked as today. Is there a better way to do this? Couldn't find any API that would give me that data pre-filtered.

Thanks

Upvotes: 1

Views: 182

Answers (1)

Greg S
Greg S

Reputation: 2079

You cannot currently filter on the server based on all of your criteria, but you can filter out completed tasks by specifying the completed_since=now query parameter. This will indicate it should only return tasks that have been completed after the current time, i.e. no complete tasks.

See https://asana.com/developers/api-reference/tasks#query for more options.

Assuming completed tasks are the majority of your assigned tasks, that should help considerably.

Upvotes: 2

Related Questions