-
Notifications
You must be signed in to change notification settings - Fork 57
Description
When fetching a large number of tasks, one should be able to request fields like dependencies be pulled as part of the bulk pull. Those fields should be usable later without the information being refetched.
How to reproduce:
tasks = client.tasks.find_all(project: project_gid, options: { fields: 'dependencies' })
tasks_with_dependencies = tasks.select { |task| task.dependencies.size == 0 }
Expected result:
Second line does not cause extra HTTP GET on the API, as the dependency information was fetched with the original client.tasks.find_all() call.
Actual result:
Second line creates O(n) extra HTTP get requests.
Workaround
Users of the SDK can call task.instance_variable_get(:@dependencies)
to check for cached dependencies instead of calling task.dependencies
.
Commentary
This bug is causing 15% of the Asana API requests in my project. While the @Dependencies variable is saved upon the initial fetch from the project, it appears the generated API code for dependencies() does not look for @dependencies
or save it afterwards:
https://github.com/Asana/ruby-asana/blob/master/lib/asana/resources/task.rb#L283-L286