From 2af91aa1780ac218949ebee2286867f18e90e912 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 8 Jan 2025 14:27:23 +0100 Subject: [PATCH] # 450 Optimization recalculate_parcels command * optimizes recalculate_parcels.py command so that only non-empty geometries will be processed * drops test_identifier_generating.py command due to missing usage --- .../commands/recalculate_parcels.py | 4 +- .../commands/test_identifier_generating.py | 51 ------------------- 2 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 konova/management/commands/test_identifier_generating.py diff --git a/konova/management/commands/recalculate_parcels.py b/konova/management/commands/recalculate_parcels.py index 42165c5f..021e3d68 100644 --- a/konova/management/commands/recalculate_parcels.py +++ b/konova/management/commands/recalculate_parcels.py @@ -34,7 +34,9 @@ class Command(BaseKonovaCommand): def recalculate_parcels(self, options: dict): force_all = options.get("force_all", False) - geometry_objects = Geometry.objects.all().exclude( + geometry_objects = Geometry.objects.filter( + geom__isempty=False, + ).exclude( geom=None ) diff --git a/konova/management/commands/test_identifier_generating.py b/konova/management/commands/test_identifier_generating.py deleted file mode 100644 index 09c35731..00000000 --- a/konova/management/commands/test_identifier_generating.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -Author: Michel Peltriaux -Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany -Contact: michel.peltriaux@sgdnord.rlp.de -Created on: 19.08.21 - -""" -from django.core.management import BaseCommand - -from intervention.models import Intervention - - -class Command(BaseCommand): - help = "Performs test on collisions using the identifier generation" - - def handle(self, *args, **options): - identifiers = {} - max_iterations = 100000 - try: - collisions = 0 - len_ids = len(identifiers) - while len_ids < max_iterations: - tmp_intervention = Intervention() - _id = tmp_intervention.generate_new_identifier() - len_ids = len(identifiers) - if _id not in identifiers: - if len_ids % (max_iterations/5) == 0: - print(len_ids) - identifiers[_id] = None - else: - collisions += 1 - print("+++ Collision after {} identifiers +++".format(len_ids)) - - except KeyboardInterrupt: - self._break_line() - exit(-1) - print( - "\n{} collisions in {} identifiers; Collision rate {}%".format( - collisions, - len_ids, - (collisions / len_ids)*100, - ) - ) - - def _break_line(self): - """ Simply prints a line break - - Returns: - - """ - self.stdout.write("\n") \ No newline at end of file