0

Getting one EventLogEntry for each Tasks

I need to retrieve one latest EventLogEntry for each of the Tasks I have.

I could call find() for all EventLogEntries and do a loop to find the latest but the find()'s result would be too large and cause performance hit. And I can't add date filter since the Tasks activities are uneven. As I understand, there is no MAX filter for Shotgun.

Is there a way to do this with one find() call?

Just to give you an idea about the speed:

Querying all EventLogEntries for 17 Tasks returns 6770 rows and takes around 9.3 seconds.

1件のコメント

  • 0
    Avatar
    Steven Parker

    SeanK, 

    Use the order filter. To find the latest entry for a given Entity, we define latest to be the most recent in Time.

    sg.find_one(
      entity_type = 'EventLogEntry',
      filters = [['entity', 'is', {'type': 'Task', 'id': 321}]],
      fields = sg.schema_field_read('EventLogEntry').keys(),
      order = [{'field_name':'created_at','direction':'desc'}]
    )

    Documentation for the find method shows several other useful params you can pass:

    https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Methods#wiki-find_one

     

    Steven

ログインしてコメントを残してください。