mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 12:19:47 -04:00
Handle areas with missing data
At the moment there are some areas which have: - a `count_of_phones` value of `None` - no sub-areas This is wrong, but until we fix the data the phone counting code needs to handle this. This commit: - adds the `or 0` in the right place (where it will catch these areas with missing data) - adds a test which checks these areas, and compares them to other kinds of areas
This commit is contained in:
@@ -59,8 +59,10 @@ class BroadcastArea(SortableMixin):
|
||||
self.polygons.estimated_area / CITY_OF_LONDON.AREA_SQUARE_MILES
|
||||
)
|
||||
if self.sub_areas:
|
||||
return sum(area.count_of_phones or 0 for area in self.sub_areas)
|
||||
return self._count_of_phones
|
||||
return sum(area.count_of_phones for area in self.sub_areas)
|
||||
# TODO: remove the `or 0` once missing data is fixed, see
|
||||
# https://www.pivotaltracker.com/story/show/174837293
|
||||
return self._count_of_phones or 0
|
||||
|
||||
|
||||
class BroadcastAreaLibrary(SerialisedModelCollection, SortableMixin, GetItemByIdMixin):
|
||||
|
||||
@@ -124,7 +124,7 @@ class BroadcastMessage(JSONModel):
|
||||
@property
|
||||
def count_of_phones(self):
|
||||
return round_to_significant_figures(
|
||||
sum(area.count_of_phones or 0 for area in self.areas),
|
||||
sum(area.count_of_phones for area in self.areas),
|
||||
2
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user