From f2a816687451f5bf5fb5dd4089c9c35ae5e43d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 24 Nov 2024 01:52:07 +0100 Subject: [PATCH] #21: Improve package parameter merging command --- .../commands/consolidate_component_package_parameters.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shimatta_kenkyusho/parts/management/commands/consolidate_component_package_parameters.py b/shimatta_kenkyusho/parts/management/commands/consolidate_component_package_parameters.py index 09d5c46..3ab4980 100644 --- a/shimatta_kenkyusho/parts/management/commands/consolidate_component_package_parameters.py +++ b/shimatta_kenkyusho/parts/management/commands/consolidate_component_package_parameters.py @@ -19,6 +19,10 @@ class Command(BaseCommand): component_parameters = ComponentParameter.objects.filter(component=component) package_param_ids = package_parameters.values_list('parameter_type_id', flat=True) component_param_ids = component_parameters.values_list('parameter_type_id', flat=True) + + # Skip trivial cases + if len(package_param_ids) == 0 or len(component_param_ids) == 0: + continue self.stdout.write(f'Comp: {str(component)} Found {len(component_param_ids)} different parameters') self.stdout.write(f'\tPackage: {str(component.package)} Found {len(package_param_ids)} different parameters') @@ -36,4 +40,4 @@ class Command(BaseCommand): if not options['dry_run']: comp_param.delete() else: - self.stderr.write(f'\tParameter {common_type.parameter_name} is set on component {str(component)} and its package with different values: "{s1}" vs "{s2}"') \ No newline at end of file + self.stderr.write(f'\tParameter {common_type.parameter_name} is set on component {str(component)} and its package with different values: "{s1}" vs "{s2}"')