Refactor logic to identify types of areas

I did consider whether to store this explicitly in the SQLite DB,
but this is less effort for now and we can always switch to that
more robust approach in future if we need to.
This commit is contained in:
Ben Thorner
2021-08-24 16:06:46 +01:00
parent bcfa21428f
commit de804805ac
2 changed files with 10 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ def _convert_custom_areas_to_wards(areas):
def _aggregate_wards_by_local_authority(areas):
return {
area.parent if area.id.startswith('wd20-')
area.parent if area.is_electoral_ward
else area for area in areas
}
@@ -56,7 +56,7 @@ def _cluster_lower_tier_authorities(areas):
for area in areas:
# group lower tier authorities by "county"
if area.id.startswith('lad20-') and area.parent:
if area.is_lower_tier_local_authority:
result[area.parent] += [area]
# leave countries, unitary authorities as-is
else: