From 8d74e9c08de12231dd9d6c0f80914c78773caad7 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 12 Aug 2020 10:17:45 +0100 Subject: [PATCH] Store names and IDs of areas in memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that the data needed to create a `BroadcastArea` is pretty lightweight because it doesn’t include the GeoJSON we can go back to putting it in memory when we start up the app, to make the pages load really fast. Rough estimate for the size of this dataset: > 10,000 areas > Average length of area name = 20 characters > Average length of area id = 20 characters > Size of one area in bytes = 20 + 20 = 40 > Size of dataset = 40 * 10,000 = 400,000 bytes = 400kb --- app/broadcast_areas/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/broadcast_areas/__init__.py b/app/broadcast_areas/__init__.py index 05775900b..a43af5a3b 100644 --- a/app/broadcast_areas/__init__.py +++ b/app/broadcast_areas/__init__.py @@ -105,14 +105,11 @@ class BroadcastAreaLibrary(SerialisedModelCollection, SortableMixin, GetItemById self.id = id self.name = name self.is_group = bool(is_group) + self.items = BroadcastAreasRepository().get_all_areas_for_library(self.id) def get_examples(self): return BroadcastAreasRepository().get_library_description(self.id) - @property - def items(self): - return BroadcastAreasRepository().get_all_areas_for_library(self.id) - class BroadcastAreaLibraries(SerialisedModelCollection, GetItemByIdMixin):