Start sending aggregate area names to API

The aggregate names don't need to be sorted, but it helps to do
this for the tests, since the implementation of sets may not be
stable between machines and lead to sporadic test failures.

I did also toy with sorting granular area names so they have a
similar ordering, but this would take them out-of-order with IDs
and really the important thing is that the ordering is stable.
This commit is contained in:
Ben Thorner
2021-08-27 14:58:45 +01:00
parent a94291d5a4
commit 4bae4eec6c
4 changed files with 16 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ from app.broadcast_areas.models import (
CustomBroadcastAreas,
broadcast_area_libraries,
)
from app.broadcast_areas.utils import aggregate_areas
from app.formatters import round_to_significant_figures
from app.models import JSONModel, ModelList
from app.models.user import User
@@ -244,6 +245,7 @@ class BroadcastMessage(JSONModel):
areas = {
'ids': self.area_ids,
'names': [area.name for area in self.areas],
'aggregate_names': [area.name for area in aggregate_areas(self.areas)],
'simple_polygons': self.simple_polygons.as_coordinate_pairs_lat_long
}