mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-06 01:19:00 -04:00
Clarify comments for aggregation algorithm
In response to [1] and [2]. [1]: https://github.com/alphagov/notifications-admin/pull/4003#discussion_r695919270 [2]: https://github.com/alphagov/notifications-admin/pull/4003#discussion_r695920213
This commit is contained in:
@@ -34,17 +34,17 @@ def _aggregate_lower_tier_authorities(areas):
|
||||
clusters = _cluster_lower_tier_authorities(areas)
|
||||
|
||||
for cluster in clusters:
|
||||
# always keep lone area as itself
|
||||
# always show a single area cluster as itself (aggregation isn't helpful)
|
||||
if len(cluster) == 1:
|
||||
results |= set(cluster)
|
||||
# aggregate multi-area cluster
|
||||
# aggregate a single cluster with lots of areas (too complex to show in full)
|
||||
elif len(cluster) > 3:
|
||||
results |= {cluster[0].parent}
|
||||
# aggregate many small clusters
|
||||
# if cluster is 2 or 3 areas, and there are more than 1 cluster, aggregate the cluster
|
||||
elif len(clusters) > 1:
|
||||
area = cluster[0]
|
||||
results |= {area.parent or area}
|
||||
# keep one small cluster in full
|
||||
# else keep single 2-3 areas cluster in full (easy enough to understand)
|
||||
else:
|
||||
results |= set(cluster)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user