diff --git a/attract/shots_and_assets/__init__.py b/attract/shots_and_assets/__init__.py index 5aee8cc..48c4ba2 100644 --- a/attract/shots_and_assets/__init__.py +++ b/attract/shots_and_assets/__init__.py @@ -138,6 +138,8 @@ class ShotAssetManager(object): """ + from pillar.web.utils import last_page_index + api = pillar_api() id_to_shot = {} @@ -147,21 +149,30 @@ class ShotAssetManager(object): id_to_shot[shot_id] = shot shot_id_to_tasks[shot_id] = collections.defaultdict(set) - found = pillarsdk.Node.all({ - 'where': { - 'node_type': node_type_task['name'], - 'parent': {'$in': list(id_to_shot.keys())}, - } - }, api=api) + page_idx = 1 + while True: + found = pillarsdk.Node.all({ + 'where': { + 'node_type': node_type_task['name'], + 'parent': {'$in': list(id_to_shot.keys())}, + }, + 'page': page_idx, + }, api=api) - known = set(known_task_types) # for fast lookups + known = set(known_task_types) # for fast lookups - # Now put the tasks into the right spot. - for task in found['_items']: - task_type = task.properties.task_type - if task_type not in known: - task_type = None - shot_id_to_tasks[task.parent][task_type].add(task) + # Put the tasks into the right spot. + for task in found['_items']: + task_type = task.properties.task_type + if task_type not in known: + task_type = None + shot_id_to_tasks[task.parent][task_type].add(task) + + # Keep looping over the pages. Result count can change between + # queries, so always recompute the last page index. + if page_idx >= last_page_index(found['_meta']): + break + page_idx += 1 return shot_id_to_tasks