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

Cached task dependencies not retrievable #125

Open
apiology opened this issue May 7, 2022 · 1 comment
Open

Cached task dependencies not retrievable #125

apiology opened this issue May 7, 2022 · 1 comment

Comments

@apiology
Copy link

apiology commented May 7, 2022

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

@apiology
Copy link
Author

Note: Same issue exists with tags, and probably other things.

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

No branches or pull requests

1 participant