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:
Chris Hill-Scott
2020-09-17 11:00:17 +01:00
parent e232950d46
commit 76244d8c07
3 changed files with 36 additions and 7 deletions

View File

@@ -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
)