Jump to content

hwo to get all tasks that were changed during some period of time


ledidukh

Recommended Posts

Since a new version gets created every time you publish you can do something like this:

 

query = 'select task, task.id, task.name from 'query += 'AssetVersion where date after "{}" and date before "{}"'.format(    arrow.now().replace(weeks=-2),     arrow.now().replace(weeks=-1))tasks = {}versions = session.query(query).all()for version in versions:    task = version['task']    if task:        tasks[task['id']] = task    for task in tasks.itervalues():    print task['name']

As for status, I don't think ftrack keeps track of the date every time a status changes. 

Link to comment
Share on other sites

To get tasks with status changes during a period of time you could try something like:

 

# Query for all change events of type status update since 2015-12-01.for event in session.query(    'select parent_id from Event where action is "change.status.task" and '    'insert is "update" and created_at > 2015-12-01'):    print session.get('TypedContext', event['parent_id'])

Be aware that to wide filters could potentially hurt performance. E.g. you will not want to query all events on the server but really try to narrow it down.

 

If you add "data" to the select you will have the new and old statusid. As you will notice the keys in the data dictionary does not exactly match the attributes on the task. E.g. statusid vs status_id. 

Link to comment
Share on other sites

And as an optimisation if you are fetching lots of entities and don't have a local cache you can fetch all matching tasks in one query:

import arrowimport ftrack_apisession = ftrack_api.Session()events = session.query(    'select parent_id from Event where action is "change.status.task" and '    'insert is "update" and created_at > 2015-12-01').all()entity_ids = [    event['parent_id'] for event in events if event['parent_type'] == 'task']tasks = []if entity_ids:    tasks = session.query(        'select name from Task where id in ("{0}")'        .format('","'.join(entity_ids))    ).all()for task in tasks:    print task['name']
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...