Take pagination into account when listing tasks for all shots.
This is a stop-gap measure; we probably want to abstract this away into something more reusable. Better to do that after switching to Python 3, though.
This commit is contained in:
@@ -138,6 +138,8 @@ class ShotAssetManager(object):
|
||||
|
||||
"""
|
||||
|
||||
from pillar.web.utils import last_page_index
|
||||
|
||||
api = pillar_api()
|
||||
|
||||
id_to_shot = {}
|
||||
@@ -147,22 +149,31 @@ class ShotAssetManager(object):
|
||||
id_to_shot[shot_id] = shot
|
||||
shot_id_to_tasks[shot_id] = collections.defaultdict(set)
|
||||
|
||||
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
|
||||
|
||||
# Now put the tasks into the right spot.
|
||||
# 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
|
||||
|
||||
def edit_shot(self, shot_id, **fields):
|
||||
|
Reference in New Issue
Block a user