new API : get all task and assignements
0

3 posts in this topic

Hi ! 

I'm trying to get all project's tasks with users assignated to them in the less possible query. 

session = ftrack_api.Session()
tasks = session.query('Task where project.full_name is "' + projectName + '" ').all()   
session.populate(tasks, 'name,status.name,assignments.context.name' )

for task in tasks : 
    with session.auto_populating(False) :
        if len(task['assignments'])> 0 :
            print( task['assignments'][0]['resource'] )

I get this : 

<Appointment(9c76e170-f0d6-11e5-861a-42010af00076)>

But when I try to get ressource attribute value from this, it's empty. 
str( task['assignments'][0]['resource']) return "NOT SET",
That must be caused by auto_populating(False)

So perhaps I need to modify my query ?
Cause if I remove auto_populating(False), I'm afraid that is gonna be slow;

Best regards 

 

Share this post


Link to post
Share on other sites

You could try session.populate(tasks, 'name,status.name,assignments.resource') instead. I know if you use assignments.resource.name it will break even though it seems like it should be valid. So you can always add name as a default projection for Task similar to this example: Default Projections

Share this post


Link to post
Share on other sites

Hi eight !

Thanks for your answer. I tried various method to get (in one query) task, task name, task status and assignated users using projection, but I wasn't able to make it works... 

This is the same problem with the custom attributes. 

If someone have an code example to show how to do that, I would be very happy :)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
0