forked from erp-dev/erp
fix: retry_failed_external_order_sync remove limit default
This commit is contained in:
@@ -15,7 +15,7 @@ class Command(BaseCommand):
|
||||
help = '基于失败记录重试外部印染 records 同步'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--limit', type=int, default=100, help='最多重试多少条失败记录')
|
||||
parser.add_argument('--limit', type=int, default=None, help='最多重试多少条失败记录;不传则重试全部')
|
||||
parser.add_argument(
|
||||
'--run-date',
|
||||
type=str,
|
||||
@@ -31,7 +31,9 @@ class Command(BaseCommand):
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
limit = max(1, int(options.get('limit') or 100))
|
||||
limit = options.get('limit')
|
||||
if limit is not None:
|
||||
limit = max(1, int(limit))
|
||||
run_date_text = options.get('run_date')
|
||||
record_ids = options.get('record_id') or []
|
||||
|
||||
@@ -59,7 +61,7 @@ class Command(BaseCommand):
|
||||
continue
|
||||
selected_failures.append(failure)
|
||||
selected_record_ids.add(failure.external_record_id)
|
||||
if len(selected_failures) >= limit:
|
||||
if limit is not None and len(selected_failures) >= limit:
|
||||
break
|
||||
|
||||
if not selected_failures:
|
||||
@@ -111,7 +113,10 @@ class Command(BaseCommand):
|
||||
external_record_id__in=succeeded_ids
|
||||
).delete()
|
||||
|
||||
remaining_failures = api_models.PrintingExternalSyncFailure.objects.count()
|
||||
|
||||
result = {
|
||||
'limit': limit,
|
||||
'retried_records': len(retry_records),
|
||||
'skipped_records': skipped_records,
|
||||
'orders_created': batch_result['orders_created'],
|
||||
@@ -121,5 +126,6 @@ class Command(BaseCommand):
|
||||
'failed_records': batch_result['failed_records'],
|
||||
'failed_record_ids': batch_result['failed_record_ids'],
|
||||
'deleted_failures': deleted_failures,
|
||||
'remaining_failures': remaining_failures,
|
||||
}
|
||||
self.stdout.write(self.style.SUCCESS(str(result)))
|
||||
Reference in New Issue
Block a user