From a0d6c153bf706167272ce3db288030f2885006fc Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 5 Jul 2021 15:24:04 +0100 Subject: [PATCH] Add comment explaining phone counting strategy --- app/models/broadcast_message.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/broadcast_message.py b/app/models/broadcast_message.py index e71f36083..cbf35d832 100644 --- a/app/models/broadcast_message.py +++ b/app/models/broadcast_message.py @@ -184,10 +184,17 @@ class BroadcastMessage(JSONModel): estimated_area = self.simple_polygons.estimated_area if estimated_area > ESTIMATED_AREA_OF_LARGEST_UK_COUNTY: + # For large areas, use a naïve but computationally less + # expensive way of counting the number of phones in the + # bleed area count = self.count_of_phones * ( self.simple_polygons_with_bleed.estimated_area / estimated_area ) else: + # For smaller areas, where the computation can be done in + # a second or less (approximately) calculate the number of + # phones based on the ammount of overlap with areas for + # which we have population data count = CustomBroadcastArea.from_polygon_objects( self.simple_polygons_with_bleed ).count_of_phones