Store names and IDs of areas in memory

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
This commit is contained in:
Chris Hill-Scott
2020-08-12 10:17:45 +01:00
parent 6c21a1732c
commit 8d74e9c08d

View File

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