From de364bba3c091e2f347b4688d62a3abd2d71a049 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 6 Aug 2021 10:11:24 +0100 Subject: [PATCH] Make `overlapping_areas` a cached property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s quite expensive to calculate and there’s no guarantee we’ll only use it once. --- app/broadcast_areas/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/broadcast_areas/models.py b/app/broadcast_areas/models.py index 4cd7f6d3b..b33ee1ee4 100644 --- a/app/broadcast_areas/models.py +++ b/app/broadcast_areas/models.py @@ -164,7 +164,7 @@ class CustomBroadcastArea(BaseBroadcastArea): simple_polygons = polygons - @property + @cached_property def overlapping_areas(self): if not self.polygons: return []