# Issue #381
* adds another validity check to SimpleGeomForm (is_size_valid) to make sure the area of the entered geometry is somehow rational (>= 1m²) * optimizes performance of django command sanitize_db * extends Geometry model with two new attributes, holding timestamps when a parcel calculation has been started and ended * finally drops unused update_parcel_wfs in favor of update_parcels in Geometry model * refactors update_parcel method * adds geometry buffer fallback in schneider/fetcher.py to avoid emptying of geometries when parcels shall be fetched * finally removes utils/wfs/spatial.py * extends GeomParcelsView according to #381 * updates translations * removes redundant psycopg2-binary requirement
This commit is contained in:
@@ -61,14 +61,24 @@ class Command(BaseKonovaCommand):
|
||||
action=UserAction.CREATED
|
||||
)
|
||||
|
||||
intervention_log_entries_ids = self.get_all_log_entries_ids(Intervention)
|
||||
attached_log_entries_id = intervention_log_entries_ids.union(
|
||||
self.get_all_log_entries_ids(Compensation),
|
||||
self.get_all_log_entries_ids(EcoAccount),
|
||||
self.get_all_log_entries_ids(Ema),
|
||||
)
|
||||
EIV_log_entries_ids = self.get_all_log_entries_ids(Intervention)
|
||||
self._write_warning(f" EIV: {EIV_log_entries_ids.count()} attached log entries")
|
||||
KOM_log_entries_ids = self.get_all_log_entries_ids(Compensation)
|
||||
self._write_warning(f" KOM: {KOM_log_entries_ids.count()} attached log entries")
|
||||
OEK_log_entries_ids = self.get_all_log_entries_ids(EcoAccount)
|
||||
self._write_warning(f" OEK: {OEK_log_entries_ids.count()} attached log entries")
|
||||
EMA_log_entries_ids = self.get_all_log_entries_ids(Ema)
|
||||
self._write_warning(f" EMA: {EMA_log_entries_ids.count()} attached log entries")
|
||||
|
||||
unattached_log_entries = all_log_entries.exclude(id__in=attached_log_entries_id)
|
||||
unattached_log_entries = all_log_entries.exclude(
|
||||
id__in=EIV_log_entries_ids
|
||||
).exclude(
|
||||
id__in=KOM_log_entries_ids
|
||||
).exclude(
|
||||
id__in=OEK_log_entries_ids
|
||||
).exclude(
|
||||
id__in=EMA_log_entries_ids
|
||||
)
|
||||
|
||||
num_entries = unattached_log_entries.count()
|
||||
if num_entries > 0:
|
||||
@@ -108,13 +118,20 @@ class Command(BaseKonovaCommand):
|
||||
self._write_warning("=== Sanitize compensation actions ===")
|
||||
all_actions = CompensationAction.objects.all()
|
||||
|
||||
compensation_action_ids = self.get_all_action_ids(Compensation)
|
||||
attached_action_ids = compensation_action_ids.union(
|
||||
self.get_all_action_ids(EcoAccount),
|
||||
self.get_all_action_ids(Ema),
|
||||
)
|
||||
kom_action_ids = self.get_all_action_ids(Compensation)
|
||||
self._write_warning(f" KOM: {kom_action_ids.count()} attached actions")
|
||||
oek_action_ids = self.get_all_action_ids(EcoAccount)
|
||||
self._write_warning(f" OEK: {oek_action_ids.count()} attached actions")
|
||||
ema_action_ids = self.get_all_action_ids(Ema)
|
||||
self._write_warning(f" EMA: {ema_action_ids.count()} attached actions")
|
||||
|
||||
unattached_actions = all_actions.exclude(id__in=attached_action_ids)
|
||||
unattached_actions = all_actions.exclude(
|
||||
id__in=kom_action_ids
|
||||
).exclude(
|
||||
id__in=oek_action_ids
|
||||
).exclude(
|
||||
id__in=ema_action_ids
|
||||
)
|
||||
|
||||
num_entries = unattached_actions.count()
|
||||
if num_entries > 0:
|
||||
@@ -125,7 +142,7 @@ class Command(BaseKonovaCommand):
|
||||
self._write_success("No unattached actions found.")
|
||||
self._break_line()
|
||||
|
||||
def get_all_deadline_ids(self, cls):
|
||||
def _get_all_deadline_ids(self, cls):
|
||||
""" Getter for all deadline ids of a model
|
||||
|
||||
Args:
|
||||
@@ -154,13 +171,20 @@ class Command(BaseKonovaCommand):
|
||||
self._write_warning("=== Sanitize deadlines ===")
|
||||
all_deadlines = Deadline.objects.all()
|
||||
|
||||
compensation_deadline_ids = self.get_all_deadline_ids(Compensation)
|
||||
attached_deadline_ids = compensation_deadline_ids.union(
|
||||
self.get_all_deadline_ids(EcoAccount),
|
||||
self.get_all_deadline_ids(Ema),
|
||||
)
|
||||
kom_deadline_ids = self._get_all_deadline_ids(Compensation)
|
||||
self._write_warning(f" KOM: {kom_deadline_ids.count()} attached deadlines")
|
||||
oek_deadline_ids = self._get_all_deadline_ids(EcoAccount)
|
||||
self._write_warning(f" OEK: {kom_deadline_ids.count()} attached deadlines")
|
||||
ema_deadline_ids = self._get_all_deadline_ids(Ema)
|
||||
self._write_warning(f" EMA: {kom_deadline_ids.count()} attached deadlines")
|
||||
|
||||
unattached_deadlines = all_deadlines.exclude(id__in=attached_deadline_ids)
|
||||
unattached_deadlines = all_deadlines.exclude(
|
||||
id__in=kom_deadline_ids
|
||||
).exclude(
|
||||
id__in=oek_deadline_ids
|
||||
).exclude(
|
||||
id__in=ema_deadline_ids
|
||||
)
|
||||
|
||||
num_entries = unattached_deadlines.count()
|
||||
if num_entries > 0:
|
||||
@@ -171,7 +195,7 @@ class Command(BaseKonovaCommand):
|
||||
self._write_success("No unattached deadlines found.")
|
||||
self._break_line()
|
||||
|
||||
def get_all_geometry_ids(self, cls):
|
||||
def _get_all_geometry_ids(self, cls):
|
||||
""" Getter for all geometry ids of a model
|
||||
|
||||
Args:
|
||||
@@ -200,14 +224,24 @@ class Command(BaseKonovaCommand):
|
||||
self._write_warning("=== Sanitize geometries ===")
|
||||
all_geometries = Geometry.objects.all()
|
||||
|
||||
compensation_geometry_ids = self.get_all_geometry_ids(Compensation)
|
||||
attached_geometry_ids = compensation_geometry_ids.union(
|
||||
self.get_all_geometry_ids(Intervention),
|
||||
self.get_all_geometry_ids(EcoAccount),
|
||||
self.get_all_geometry_ids(Ema),
|
||||
)
|
||||
kom_geometry_ids = self._get_all_geometry_ids(Compensation)
|
||||
self._write_warning(f" EMA: {kom_geometry_ids.count()} attached geometries")
|
||||
eiv_geometry_ids = self._get_all_geometry_ids(Intervention)
|
||||
self._write_warning(f" EMA: {eiv_geometry_ids.count()} attached geometries")
|
||||
oek_geometry_ids = self._get_all_geometry_ids(EcoAccount)
|
||||
self._write_warning(f" EMA: {oek_geometry_ids.count()} attached geometries")
|
||||
ema_geometry_ids = self._get_all_geometry_ids(Ema)
|
||||
self._write_warning(f" EMA: {ema_geometry_ids.count()} attached geometries")
|
||||
|
||||
unattached_geometries = all_geometries.exclude(id__in=attached_geometry_ids)
|
||||
unattached_geometries = all_geometries.exclude(
|
||||
id__in=kom_geometry_ids
|
||||
).exclude(
|
||||
id__in=eiv_geometry_ids
|
||||
).exclude(
|
||||
id__in=oek_geometry_ids
|
||||
).exclude(
|
||||
id__in=ema_geometry_ids
|
||||
)
|
||||
|
||||
num_entries = unattached_geometries.count()
|
||||
if num_entries > 0:
|
||||
@@ -218,7 +252,7 @@ class Command(BaseKonovaCommand):
|
||||
self._write_success("No unattached geometries found.")
|
||||
self._break_line()
|
||||
|
||||
def get_all_state_ids(self, cls):
|
||||
def _get_all_state_ids(self, cls):
|
||||
""" Getter for all states (before and after) of a class
|
||||
|
||||
Args:
|
||||
@@ -254,14 +288,19 @@ class Command(BaseKonovaCommand):
|
||||
"""
|
||||
self._write_warning("=== Sanitize compensation states ===")
|
||||
all_states = CompensationState.objects.all()
|
||||
compensation_state_ids = self.get_all_state_ids(Compensation)
|
||||
account_state_ids = self.get_all_state_ids(EcoAccount)
|
||||
ema_state_ids = self.get_all_state_ids(Ema)
|
||||
attached_state_ids = compensation_state_ids.union(account_state_ids, ema_state_ids)
|
||||
|
||||
kom_state_ids = self._get_all_state_ids(Compensation)
|
||||
oek_state_ids = self._get_all_state_ids(EcoAccount)
|
||||
ema_state_ids = self._get_all_state_ids(Ema)
|
||||
|
||||
unattached_states = all_states.exclude(
|
||||
id__in=attached_state_ids
|
||||
id__in=kom_state_ids
|
||||
).exclude(
|
||||
id__in=oek_state_ids
|
||||
).exclude(
|
||||
id__in=ema_state_ids
|
||||
)
|
||||
|
||||
num_unattached_states = unattached_states.count()
|
||||
if num_unattached_states > 0:
|
||||
self._write_error(f"Found {num_unattached_states} unused compensation states. Delete now...")
|
||||
|
||||
Reference in New Issue
Block a user