Alex Sknarin Posted May 28, 2020 Report Share Posted May 28, 2020 Hi For example I have list of projects: Project01 Project02 Project03 Project04 I also have some user assigned to some tasks in Project02 and Project03. How could I query only that projects? Link to comment Share on other sites More sharing options...
Yas Opisso Posted May 28, 2020 Report Share Posted May 28, 2020 What's your end goal? Find a list of projects that user X is assigned to? If so I would instead query the assignments for the user and find the project from there. Link to comment Share on other sites More sharing options...
Yas Opisso Posted May 28, 2020 Report Share Posted May 28, 2020 Here is a quick example; let's suppose you have the user ID and you need to find out the list of projects he/she has assigned. session = #<build your session here> user_id = '805cf360-115e-11e5-ax81-002593f15914' # This query looks at active projects only task_query = 'select project.id, project.name, project.full_name from Task where project.status is active and assignments any (resource_id={})'.format(user_id) ft_tasks = session.query(task_query).all() for task in ft_tasks: project_id = task['project']['id'] project_code = task['project']['name'] project_name = task['project']['full_name'] print(project_code, project_name, project_id) Link to comment Share on other sites More sharing options...
Alex Sknarin Posted May 28, 2020 Author Report Share Posted May 28, 2020 Quote Find a list of projects that user X Yes I have standalone tool that used list of projects that's loaded from Ftrack. I need to show only projects that user is involved in. Quote If so I would instead query the assignments for the user and find the project from there. Ah, get from user side. Ok I'll try but I will need to get list of all tasks that artist is assigned to so it could be slower Link to comment Share on other sites More sharing options...
Alex Sknarin Posted May 28, 2020 Author Report Share Posted May 28, 2020 oh, projection should be fast enough. Thank you. Just to clarify: Project dosen't have some property that holds users from tasks? Yas Opisso 1 Link to comment Share on other sites More sharing options...
Yas Opisso Posted May 28, 2020 Report Share Posted May 28, 2020 If you want to go directly through the project, you can look at its "assignments" key. You can tweak the code above to query Assignment instead of Task. Edit: Although to be fair I'm not sure the "assignments" key in a project will give you assignments for every children. I don't believe the project has assignee so it might work. I haven't tried doing so this way. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now