1

So I have a little bit of a dilemma in trying to obtain the oldest task of a user. I’m able to get the oldest task of each user in my team's workspace, but takes 1 hour and 30 minutes to run.

Here's the current workflow that I have currently:

1) Get all users and store in a users var.
2) Iterate through all users.
3) For each user, grab all tasks and store in a tasks var.
4) Iterate through all tasks, compare task.modified_at attribute to oldest_task var, store in oldest_task if task.modified_at is older.

What's taking so long is the loading of and iterating through each user's tasks. Any ideas on how to make this process faster? Would there potentially be a way to query specifically for the oldest task of a user through the API?

I’m building a tool that will track the age of the oldest task for each user for tracking purposes. I would love to find out if there’s something that I’m missing.

irmiller22
  • 172
  • 6

1 Answers1

1

For oldest task you should probably use created_at rather than modified_at (the oldest task could have been modified recently, after all).

We don't have any way in the API to specifically get the older task, or order by creation time or anything like that, so for now your workaround is in fact the only way to do it. You may be able to make it a little faster by using ?opt_fields=created_at in the task query to cut down on how much data you're loading.

agnoster
  • 3,744
  • 2
  • 21
  • 29
  • any plan to allow us to do this in the future? It will certainly ease the pain of your servers ;) – analogue Jul 07 '15 at 22:11
  • 1
    It's not on our roadmap - this is really the first time I've heard of someone wanting the oldest task assigned to a user. What exactly is the goal of this? Could you explain a bit more what you want this for? Off the top of my head it's hard to imagine what it's useful for. – agnoster Jul 08 '15 at 08:57
  • We are looking to set up metrics and alerts to detect stale tasks (e.g. the task that's not been touched for the longest time) per user, to remind people to take action on them. Also to know what's going on as we grow. – analogue Jul 09 '15 at 14:24
  • Interesting. This wouldn't work at all for us because we use Asana tasks to represent all kinds of things, like areas of responsibility, manager relationships, etc that would never be completed. If you *only* use task to represent actual work-to-be-done I suppose this could work? You can certainly use `?completed_since=now` at least to eliminate needing to look through already complete tasks, but that's the only shortcut I can think of. When we eventually add advanced search it should be possible to do that, but it's not on our concrete roadmap yet. – agnoster Jul 09 '15 at 20:55
  • We do too, but we can filter them by tags and projects too to rule out the non legit tasks. Ideally we could add those filters in the API call ;) – analogue Jul 10 '15 at 21:22