Skip to content

Commit 03e5b09

Browse files
committed
Merge branch 'fix-issue-46'
Resolves #46. Release v1.3.1.
2 parents 001f209 + 6752a23 commit 03e5b09

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

django/sierra/export/tasks.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,6 @@ def _fetch_job_pk_lists(exp, plan):
374374
return pk_lists
375375

376376

377-
def _initialize_job_plan(exp, plan, pk_lists):
378-
registry = plan.generate(pk_lists)
379-
totals = plan.totals
380-
total_op_chunks = totals['chunks_by_op']
381-
exp.log('Info', 'Job plan initialized. {} total chunk(s) grouped into {} '
382-
'batch(es):'.format(totals['chunks'], totals['batches']))
383-
for op in plan.operations:
384-
exp.log('Info', ' {}, {} chunk(s)'.format(op, total_op_chunks[op]))
385-
return plan
386-
387-
388377
def _apply_pk_sort_order(qset):
389378
if hasattr(qset.model, 'record_metadata'):
390379
return qset.order_by('record_metadata__record_last_updated_gmt', 'pk')
@@ -435,9 +424,15 @@ def delegate_batch(vals_list, instance_pk, export_filter, export_type, options,
435424
pk_lists = _fetch_job_pk_lists(exp, plan)
436425
exp.log('Info', 'Initializing job plan.')
437426
plan.generate(pk_lists)
438-
exp.log('Info', _hr_line())
439-
plan.log_plan_summary(exp)
440-
exp.log('Info', _hr_line())
427+
if plan.registry:
428+
exp.log('Info', _hr_line())
429+
plan.log_plan_summary(exp)
430+
exp.log('Info', _hr_line())
431+
else:
432+
msg = ('No records found for {}. Nothing to do!'
433+
''.format(', '.join(pk_lists.keys())))
434+
exp.log('Info', msg)
435+
441436

442437
elif prev_batch_had_errors:
443438
vals_list = _compile_vals_list_for_batch(prev_batch_task_id)
@@ -455,7 +450,7 @@ def delegate_batch(vals_list, instance_pk, export_filter, export_type, options,
455450
exp.options)
456451

457452
batch_tasks = []
458-
for task_chunk_id in plan.registry[batch_id]:
453+
for task_chunk_id in plan.registry.get(batch_id, []):
459454
kwargs = {'chunk_id': task_chunk_id}
460455
batch_tasks.append(do_export_chunk.s(cumulative_vals, *args, **kwargs))
461456

0 commit comments

Comments
 (0)