How to get the section a task is in? - asana

Is there a way to get the section a task is/was in from the API.
I see how we could use the entire project Json to figure it out. But once a task is completed it jumps to the top of the page. Wondering how to figure out what section it was in if it's complete.

In the API response we don't make tasks "jump" to the top - the position is kept in priority order, and should still be located under the section it belongs to.
Of course, this isn't a terribly elegant way to do it. We're currently considering how to handle Sections in the API in a better way, but we don't have a concrete plan for it yet and it's not yet on the actual roadmap.
But in the meantime, you should be able to get the project, as you said, and just look at which Section (i.e. a task that ends in ":") the tasks come after, and you're set!

Related

Check of Microsoft 365 Planner task was updated, if true then feedback with microsoft graph API

I am searching for a solution to get a automated feedback, when a planner task is changed.
Why? We use a planner to assign task to a person in the team. This person can change the tasks details. I only get a feedback if the person finishes the task.
But not if the person changes the other details. The team is big,so I can‘t check every assigned task.
Powerautomate helps not much in this.
I just started using Microsoft Graph and I prefere scipting over using powerautomate.
My question:
Is there an Object that looks at the changes in a specific planner task globally or do I have to check each detail in the task?
And can I run this hourly every day until the task is closed?
We're looking into setting up web hooks, which I think will be the way to solve this scenario. However, before we have that, I don't think there is much to support to achieve this. Since everything is in the same plan, you can probably remember the etags of the tasks, and see if they have changed, if they have, then send the reports about them. But the etags are going to be updated for any change, even if the change isn't something you care about (e.g. just moving the task around in the board). Also, task and task details have separate etags, the details can be updated without the task etag changing, so this isn't a simple solution.

Using Asana events API for task monitoring

I'm trying to use Asana events API to track changes in one of our projects, more specific task movement between sections.
Our workflow is as follows:
We have a project divided into sections.
Each section represents a
step in the process. When one step is done, the task is moved to
section below.
When a given task reaches a specific step we want to pass it to an external system. It doesn't have to be the full info - basic things + url would be enough.
My idea was to use https://asana.com/developers/api-reference/events to implement a pull-based mechanism to obtain recent changes in tasks.
My problems are:
Events API seem to generate a lot of information, but not the useful ones. Moving one single task between sections generates 3 events (2 "changed" actions, one "added" action marked as "system"). During work many tasks will be moved between many sections, but I'm interested one in one specific sections. How can I finds items moved into that section? I know that there's a
resource->text field, but it gives me something like moved from X to Y (ProjectName) which probably is a human readable message that might change in the future
According to documentation the resource key should contain task data, but the only info I see is id and name which is not enough for my case. Is it possible to get hold on tags using events API? Or any other data that would allow us to classify tasks in our system?
Can I listen for events for a specific section instead of tracking the whole project?
Ideas or suggestions are welcome. Thanks
In short:
Yes, answer below.
Yes, answer below.
Unfortunately not, sections are really tasks with a bit of extra functionality. Currently the API represents the relationship between sections and the tasks in them via the memberships field on a task and not the other way.
This should help you achieve what you are looking for, I think.
Let's say you have a project Ninja Pipeline with 2 sections Novice & Expert. Keep in mind, sections are really just tasks whose name ends with a : character with a few extra features in that tasks can belong to them.
Events "bubble up" from children to their parents; therefore, when you the Wombat task in this project form the Novice section to Expert you get 3 events. Starting from the top level going down, they are:
The Ninja Pipeline project changed.
The Wombat task changed.
A story was added to the Wombat task.
For your use case, the most interesting event is the second one about the task changing. The data you really want to know is now that the task changed what is the value of the memberships field on the task. If it is now a member of the section you are interested in, take action, otherwise ignore.
By default, many resources in the API are represented in compact form which usually only includes the id & name. Use the input/output options in order to expand objects or select specific fields you need.
In this case your best bet is to include the query parameter opt_expand=resource when polling events on the project. This should expand all of the resource objects in the payload. For events of type: "task" then if resource.memberships[0].section.id=<id_of_the_section> is true, take action, otherwise ignore.

Get info about latest created and completed tasks in asana

I need to maintain list if all user's incomplete tasks with asana API.
Right now, the best solution I came up with is polling asana for every X minutes and use /tasks with completed_since filter. However this is inefficient, since I have to perform exactly one call for every workspace.
The next thing I tried was looking into /events API, but events are generated only for projects and tasks. I got about 25 projects so it isn't the best solution either.
Is there any way I could check for updates efficiently?
Thanks.
Actually, "exactly one call per workspace" is as good as it's gonna get - we scope each request to a workspace (in fact, it's likely that in the future each API call will need to be explicitly scoped to a workspace). It's a hard IP boundary, so basically we never "mix" data from different workspaces (except for certain exceptions, like "listing the workspaces I'm in").
If you're specifically only looking for updates to tasks, you could also use modified_since.

How do i retrieve the tasks for a project under the priority heading?

How do i retrieve the tasks for a project under the priority heading?
For example i have recruitment project, i want to retrieve tasks under "Interviewed" heading (priority heading)
Thanks
There isn't currently a way to only get tasks in a given section, so the only way to do this at the moment is to fetch all tasks for the project and then filter on your side. Fortunately, the API will return the tasks in the appropriate order such that all the tasks in a given section appear after it.
It's clunky, and we do intend to provide better support for sections at some point in the future, but it's not on our immediate roadmap so I'd definitely recommend this workaround for now. If the response is simply too large, one hack could be to get the ID of the "Interviewed:" task, then fetch only the IDs from the project (GET /projects/.../tasks?opt_fields=id), and then iterate over the tasks by ID. I'd only recommend this approach if the project is genuinely too big to fetch at once, though.

Letting something happen at a certain time with Rails

Like with browser games. User constructs building, and a timer is set for a specific date/time to finish the construction and spawn the building.
I imagined having something like a deamon, but how would that work? To me it seems that spinning + polling is not the way to go. I looked at async_observer, but is that a good fit for something like this?
If you only need the event to be visible to the owning player, then the model can report its updated status on demand and we're done, move along, there's nothing to see here.
If, on the other hand, it needs to be visible to anyone from the time of its scheduled creation, then the problem is a little more interesting.
I'd say you need two things. A queue into which you can put timed events (a database table would do nicely) and a background process, either running continuously or restarted frequently, that pulls events scheduled to occur since the last execution (or those that are imminent, I suppose) and actions them.
Looking at the list of options on the Rails wiki, it appears that there is no One True Solution yet. Let's hope that one of them fits the bill.
I just did exactly this thing for a PBBG I'm working on (Big Villain, you can see the work in progress at MadGamesLab.com). Anyway, I went with a commands table where user commands each generated exactly one entry and an events table with one or more entries per command (linking back to the command). A secondary daemon run using script/runner to get it started polls the event table periodically and runs events whose time has passed.
So far it seems to work quite well, unless I see some problem when I throw large number of users at it, I'm not planning to change it.
To a certian extent it depends on how much logic is on your front end, and how much is in your model. If you know how much time will elapse before something happens you can keep most of the logic on the front end.
I would use your model to determin the state of things, and on a paticular request you can check to see if it is built or not. I don't see why you would need a background worker for this.
I would use AJAX to start a timer (see Periodical Executor) for updating your UI. On the model side, just keep track of the created_at column for your building and only allow it to be used if its construction time has elapsed. That way you don't have to take a trip to your db every few seconds to see if your building is done.

Resources